RmDir
Removes an existing directory or folder.
Syntax: RmDir path
- path
- A string expression that identifies the directory or folder to be removed. The path may include the drive. If no drive is specified, RmDir removes the directory or folder on the current drive.
RmDir removes only an empty folder. To remove a folder that holds files, delete them first with the Kill statement.
Common Errors
| Error | When |
|---|---|
-2147467259 (&H80004005), Unspecified error | no folder has the name path, which includes a file, a zero-length string, and a name with a wildcard or a character a name cannot hold the folder holds a file or a folder, or it is the current directory |
94 (&H5E), Invalid use of Null | path is Null |
Note BETA 1034
When no folder has the name path, which includes a file, a zero-length string, and a name with a wildcard or a character a name cannot hold, VB6 and 64-bit VBA raise error 76 (&H4C), Path not found, instead.
Note BETA 1034
When the folder holds a file or a folder, or it is the current directory, VB6 and 64-bit VBA raise error 75 (&H4B), Path/File access error, instead.
See Also
Example
This example uses the RmDir statement to remove an existing directory or folder.
' Assume that MYDIR is an empty directory or folder.
RmDir "MYDIR" ' Remove MYDIR.