'Make use of the RecycleBin
'make a new project with a form (name = frmDeleteFiles)
'put the code in the right places (use Insert/File)
'press F5

'on a module form
Option Explicit

Public 

type

SHFILEOPSTRUCT hWnd

as

Long wFunc

as

Long pFrom

as

String pTo

as

String fFlags

as

Integer fAborted

as

Boolean hNameMaps

as

Long sProgress

as

String End Type Declare Function SHFileOperation Lib "shell32.dll" (lpFileOP

as

SHFILEOPSTRUCT)

as

Long Type BrowseInfo hWndOwner

as

Long pIDLRoor

as

Long pszDisplayName

as

Long lpszTitle

as

Long ulFlags

as

Long lpfnCallback

as

Long lParam

as

Long iImage

as

Long End Type Public Const BIF_RETURNONLYFSDIRS = 1 Public Const MAX_PATH = 260 Public Declare

sub

CoTaskMemFree Lib "ole32.dll" (ByVal hMem

as

Long) Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1

as

String, ByVal lpString2

as

String)

as

Long Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi

as

BrowseInfo)

as

Long Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList

as

Long, ByVal lpBuffer

as

String)

as

Long Public Function blnDeleteFilesToRecycleBin(ParamArray vntFilename()

as

Variant)

as

Boolean

on

Error GoTo ErrorToRecycleBin

dim

intK

as

Integer

dim

strFiles

as

String

dim

udtShellFileOper

as

SHFILEOPSTRUCT

dim

lngResult

as

Long For intK = LBound(vntFilename) To UBound(vntFilename) strFiles = strFiles & vntFilename(intK) & vbNullChar Next strFiles = strFiles & vbNullChar With udtShellFileOper .wFunc = &H3 .pFrom = strFiles .fFlags = &H40

end

With lngResult = SHFileOperation(udtShellFileOper) blnDeleteFilesToRecycleBin = True

exit

Function ErrorToRecycleBin: blnDeleteFilesToRecycleBin = False

exit

Function End Function Public Function strChooseFolder(hWndOwner

as

Long, strPrompt

as

String)

as

String

dim

intNull

as

Integer

dim

lngIDList

as

Long

dim

lngResult

as

Long

dim

strPath

as

String

dim

udtBI

as

BrowseInfo With udtBI .hWndOwner = hWndOwner .lpszTitle = lstrcat(strPrompt, "") .ulFlags = BIF_RETURNONLYFSDIRS

end

With lngIDList = SHBrowseForFolder(udtBI) If lngIDList Then strPath = String$(MAX_PATH, 0) lngResult = SHGetPathFromIDList(lngIDList, strPath) Call CoTaskMemFree(lngIDList) intNull = InStr(strPath, vbNullChar) If intNull Then strPath = Left$(strPath, intNull - 1)

end

If

end

If strChooseFolder = strPath End Function 'on the form called frmDeleteFiles Private

sub

Form_Load()

dim

strPath

as

String

dim

blnResult

as

Boolean strPath = strChooseFolder(Me.hWnd, "Choose a folder") If Not blnDeleteFilesToRecycleBin(strPath & "\*.url") Then MsgBox "error" Unload frmDeleteFiles End Sub Private

sub

Form_Unload(Cancel

as

Integer) End End Sub
Return