Option Explicit
Option Compare Text
Dim Fso As Object
Sub Test()
Delfile "jpg"
End Sub
Sub Delfile(Optional Ext = "jpg")
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show Then
Set Fso = CreateObject("Scripting.FileSystemObject")
KillJpg .SelectedItems(1), Ext
Set Fso = Nothing
End If
End With
End Sub
Sub KillJpg(Folder, Ext)
Dim File, Sf
Debug.Print Folder
With Fso.getfolder(Folder)
For Each File In .Files
If Fso.GetExtensionName(File) = Ext Then
Debug.Print vbTab, File.Name
File.Delete
End If
Next
For Each Sf In .SubFolders
KillJpg Sf, Ext
Next
End With
End Sub