Access/VBA Library

GetDrives

Returns Dictionary containing all mapped drives on the system.

Syntax

GetDrives()
Return value

Dictionary : Alle mapped drives. The keys are the drive letters (like, H, K, and P).

Code
Public Function GetDrives() As Dictionary
    Dim drives As New Dictionary
    Dim i As Integer
    With CreateObject("WScript.Network").EnumNetworkDrives
        For i = 0 To .Count - 1 Step 2
            Call drives.Add(GetDriveLetter(.Item(i)), .Item(i + 1))
        Next i
    End With

    Set GetDrives = drives
End Function
Filesystemtag:FilesystemNetworktag:NetworkDictionarytag:Dictionary

See also

  • GetDriveLetter
Example
Dim drives As Dictionary
Dim drive
Set drives = GetDrives()
For Each drive In drives
    Debug.Print drive, drives(drive)
Next drive