I want to know if it\'s possible to rewrite this piece of code:
Private Sub PrepareDir(ByVal dir As String)
Dim fso As New FileSystemObject
If fso.Fo
No need to delete files for Deleting folders. Take the path and search for the sub folders in a loop and that sub folder can be deleted. below is the example :copy both procedures and paste on module
Public Function Delete_Folder(ByVal FldrName As String) Dim fso, FSfolder As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set FSfolder = fso.GetFolder(Application.DefaultFilePath)' This is My Documents folder path
'You can replace with your original folder path
For Each Folder In FSfolder.SubFolders
'Debug.Print Folder.Name
If Folder.Name = FldrName Then
Folder.Delete
Exit For
End If
Next
End Function
Sub test() Delete_Folder "Sub_Folder_Name" End Sub