Drive object

Provides access to the properties of a particular disk drive or network share.

Remarks

The following code illustrates the use of the Drive object to access drive properties.

Sub ShowFreeSpace(drvPath)
    Dim fs, d, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d = fs.GetDrive(fs.GetDriveName(drvPath))
    s = "Drive " & UCase(drvPath) & " - " 
    s = s & d.VolumeName  & vbCrLf
    s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0) 
    s = s & " Kbytes"
    MsgBox s
End Sub

Collections

Collection Description
Drives Read-only collection of all available drives.

Properties

Property Description
AvailableSpace Returns the amount of available space to a user on a specified drive or network share.
DriveLetter Returns one uppercase letter that identifies the local drive or a network share.
DriveType Returns the type of a specified drive.
FileSystem Returns the file system in use for a specified drive.
FreeSpace Returns the amount of free space to a user on a specified drive or network share.
IsReady Returns true if the specified drive is ready, and false if not.
Path Returns an uppercase letter followed by a colon that indicates the path name for a specified drive.
RootFolder Returns a Folder object that represents the root folder of a specified drive.
SerialNumber Returns the serial number of a specified drive.
ShareName Returns the network share name for a specified drive.
TotalSize Returns the total size of a specified drive or network share.
VolumeName Sets or returns the volume name of a specified drive.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.