VBA GetDriveName

The FileSystemObject VBA GetDriveName function returns a string with the name of the drive for the specified path.

VBA GetDriveName Syntax

1
fso.GetDriveName( path )

path
The path for which the drive name is supposed to be specified.

VBA GetDriveName Examples

1
2
3
4
5
6
7
Set fso = CreateObject("Scripting.FileSystemObject")
 
fso.GetDriveName("C:\Src") 'Result: C:
 
fso.GetDriveName("C:\") 'Result: C:
 
fso.GetDriveName("D:\SomeFolder\SubFolder") 'Result: D: