The FileSystemObject VBA DeleteFolder function deletes a specified folder or folders.
- BuildPath
- CopyFile
- CopyFolder
- CreateFolder
- CreateTextFile
- DeleteFile
- DeleteFolder
- DriveExists
- FileExists
- FolderExists
- GetAbsolutePathName
- GetBaseName
- GetDrive
- GetDriveName
- GetExtensionName
- GetFile
- GetFileName
- GetFolder
- GetParentFolderName
- GetSpecialFolder
- GetTempName
- MoveFile
- MoveFolder
- OpenTextFile
VBA DeleteFolder Syntax
1 | fso.DeleteFolder( foldername, [ force ] ) |
foldername
The location names of folder(s) to delete. You can use wildcards such as *.* to specify more than a single folder matching the pattern.
force
Optional. If True only read-only folders are deleted. If False any folders are deleted. False is default.
VBA DeleteFolder Examples
1 2 3 4 5 6 7 8 9 10 | Set fso = CreateObject( "Scripting.FileSystemObject" ) 'Delete specified folder fso.DeleteFolder "C:\Src" 'Delete all Sub Subfolders within the C:\Src folder fso.DeleteFolder "C:\Src\*\Sub" 'Delete all subfolders fso.DeleteFolder "C:\Src\*" |