VBA Delete Folder with DeleteFolder (FSO)
This short tutorial will demonstrate how to use DeleteFolder method of the FileSystemObject.
Delete Folder with VBA FileSystemObject
This lesson uses the FileSystemObject. In order to use it, you will need to set a reference to the VB script run-time library. See here for more information.
Deleting folders is easy using DeleteFolder method of the FileSystemObject.
Sub FSODeleteFolder()
Dim FSO As New FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFolder "C:\TestFolder", False
End Sub
If the optional ’force’ part at the end of the FSO.DeleteFolder line is set to True, folders with the read-only attribute set can be also deleted.