Looks like your trying to send files to the Recycle Bin.
Code:
Private Declare Function SHFileOperation _
Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As _
SHFILEOPSTRUCT) As Long
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Type OPENFILENAME
lStructSize As Long
HwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type
Sub Recycler(hwnd As Long)
Dim typOperation As SHFILEOPSTRUCT
Dim ofn As OPENFILENAME
Dim button As Long
ofn.lStructSize = Len(ofn)
ofn.HwndOwner = hwnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "*.*"
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = "Choose a file"
ofn.flags = 0
Dim lngRetVal As Long
lngRetVal = GetOpenFileName(ofn)
If (lngRetVal) Then
With typOperation
.wFunc = FO_DELETE
.pFrom = Trim$(ofn.lpstrFile)
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation typOperation
End If
Exit Sub
End Sub
Private Sub Command1_Click()
Call Recycler(hwnd)
End Sub