Niquet.nl

Tonen lijst met alle aanwezige drives (Filesystemobject)

Met de volgende code genereer je een berichtenvenster met alle drives:

Sub drives()

    Dim fso As FileSystemObject
    Dim driveColl As drives
    Dim drive As drive
    
    txtDrives = ""
    
    Set fso = New FileSystemObject
    Set driveColl = fso.drives
    
    For Each drive In driveColl
        txtDrives = txtDrives & "Drive Letter: " & drive.DriveLetter '& vbCrLf
        
        If drive.IsReady Then
            txtDrives = txtDrives & " / Ready: " & drive.VolumeName
            
        Else
            txtDrives = txtDrives & " / Not ready" & vbCrLf
        End If
        txtDrives = txtDrives & vbCrLf
    Next

    MsgBox txtDrives

End Sub

Leave a Comment