The FileSystemObject VBA GetDriveName function returns a string with the name of the drive for the specified path.
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 GetDriveName Syntax
fso.GetDriveName( path )
path
The path for which the drive name is supposed to be specified.
VBA GetDriveName Examples
Set fso = CreateObject("Scripting.FileSystemObject") fso.GetDriveName("C:\Src") 'Result: C: fso.GetDriveName("C:\") 'Result: C: fso.GetDriveName("D:\SomeFolder\SubFolder") 'Result: D: