The FileSystemObject VBA DriveExists function returns True if the drive exists otherwise will return False.
- 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 DriveExists Syntax
1 | fso.DriveExits( drivepath ) |
drivepath
A string representing the drive letter or path to the drive.
VBA DriveExists Examples
Below examples assume drive “C” exists and no other drives exists on workstation:
1 2 3 4 5 | Set fso = CreateObject( "Scripting.FileSystemObject" ) Debug.Print fso.DriveExists( "C" ) 'Result: True Debug.Print fso.DriveExists( "E" ) 'Result: False |