The FileSystemObject VBA DriveExists function returns True if the drive exists otherwise will return False.
VBA FileSystemObject Methods
- 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
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:
Set fso = CreateObject("Scripting.FileSystemObject") Debug.Print fso.DriveExists("C") 'Result: True Debug.Print fso.DriveExists("E") 'Result: False