Drives property (Visual Basic for Applications) | Microsoft Learn

PHOTO EMBED

Mon May 06 2024 20:53:39 GMT+0000 (Coordinated Universal Time)

Saved by @acassell

Sub ShowDriveList
    Dim fs, d, dc, s, n
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives
    For Each d in dc
        s = s & d.DriveLetter & " - " 
        If d.DriveType = 3 Then
            n = d.ShareName
        Else
            n = d.VolumeName
        End If
        s = s & n & vbCrLf
    Next
    MsgBox s
End Sub
content_copyCOPY

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/drives-property