I have this vba code that deletes files of a specific type ("File") from the path indicated by the range name ("TMPath"):
Sub JunkFiles()
I want to delete these files from all subfolders within the specified folder (fPath). How can this code be modified to loop through all subfolders of this folder?
Thanks,
Sam
Sub JunkFiles()
fPath = [TMPath]
Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = fso.GetFolder(fPath)
For Each file In folder.Files
If fso.GetFile(file).Type = "File" Then
file.Delete
End If
Next
Set folder = Nothing
Set fso = Nothing
End SubSet fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = fso.GetFolder(fPath)
For Each file In folder.Files
If fso.GetFile(file).Type = "File" Then
file.Delete
End If
Next
Set folder = Nothing
Set fso = Nothing
I want to delete these files from all subfolders within the specified folder (fPath). How can this code be modified to loop through all subfolders of this folder?
Thanks,
Sam