VBA GetDrive

The FileSystemObject VBA GetDrive returns a Drive object based on the specified.

VBA GetDrive Syntax

1
fso.GetDrive( path )

path
A path that you want to convert to unambiguous file and folder.

VBA GetDrive Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive("C:")
 
'Now you can use the Drive object to get drive properties such as below
Debug.Print d.AvailableSpace 'Available space on drive
Debug.Print d.DriveLetter 'Result: "C:"
Debug.Print d.DriveType
Debug.Print d.FileSystem
Debug.Print d.FreeSpace
Debug.Print d.IsReady
Debug.Print d.RootFolder
Debug.Print d.SerialNumber
Debug.Print d.ShareName
Debug.Print d.TotalSize
Debug.Print d.VolumeName