Returns a string that describes the drive type : Drive « File Path « VBA / Excel / Access / Word






Returns a string that describes the drive type

 
Private Declare Function GetDriveType32 Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Function DriveType(DriveLetter As String) As String
    DLetter = Left(DriveLetter, 1) & ":"
    DriveCode = GetDriveType32(DLetter)
    Select Case DriveCode
        Case 1: DriveType = "Local"
        Case 2: DriveType = "Removable"
        Case 3: DriveType = "Fixed"
        Case 4: DriveType = "Remote"
        Case 5: DriveType = "CD-ROM"
        Case 6: DriveType = "RAM Disk"
        Case Else: DriveType = "Unknown Drive Type"
    End Select
End Function
Sub Main()
  Debug.Print DriveType("c:\")
End Sub

 








Related examples in the same category

1.Get Drive Information
2.The TypeOfDrive Function
3.The NumberOfBytesFree Function
4.Returns the number of free bytes for a drive
5.Returns the total storage capacity for a drive
6.Returns True if a specified drive letter exists
7.Returns the number of drives
8.Returns the drive letter using an index
9.Display Drive information