VBA GetDriveName

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

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: