Sub Test()
Set objFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Select Folder !", 0)
If Not objFolder Is Nothing Then
MyPath = objFolder.Items.Item.Path
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFolder = FSO.GetFolder(MyPath)
Set MyFiles = MyFolder.Files
For Each File In MyFiles
FileExt = FSO.GetExtensionname(File)
If FileExt = "txt" Or FileExt = "xlsx" Or FileExt = "xls" Then File.Delete
Next
End If
Set FSO = Nothing
Set MyFiles = Nothing
Set MyFolder = Nothing
End Sub
Sub Main()
Dim WshShell As Object
Dim Folder1 As String, Folder2 As String, Folder3 As String
Folder1 = "Data_1"
Folder2 = "Data_2"
Folder3 = "Data_3"
Set WshShell = CreateObject("WScript.Shell")
DesktopPath = WshShell.SpecialFolders("Desktop")
Call Clean_Folders(DesktopPath & Application.PathSeparator & Folder1)
Call Clean_Folders(DesktopPath & Application.PathSeparator & Folder2)
Call Clean_Folders(DesktopPath & Application.PathSeparator & Folder3)
Set WshShell = Nothing
End Sub
'
Sub Clean_Folders(MyPath As String)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MyFolder = FSO.GetFolder(MyPath)
Set MyFiles = MyFolder.Files
For Each File In MyFiles
FileExt = FSO.GetExtensionname(File)
If FileExt = "txt" Or FileExt = "xlsx" Or FileExt = "xls" Then File.Delete
Next
Set MyFiles = Nothing
Set MyFolder = Nothing
Set FSO = Nothing
End Sub