Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where is my CD drive 1

Status
Not open for further replies.

JesOakley

Programmer
Jan 21, 2008
42
GB
Hi,

Does anyone know of a way (using vba) to tell which drive letter equates to the CD drive? My back-end db is running off CD, but some users have C drives partitioned into C and D drives.
 
Have a look at DriveType for the FileSystemObject Drive Object.

Code:
Sub ShowDriveType(drvpath)
    Dim fs, d, s, t
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set d = fs.GetDrive(drvpath)
    Select Case d.DriveType
        Case 0: t = "Unknown"
        Case 1: t = "Removable"
        Case 2: t = "Fixed"
        Case 3: t = "Network"
        Case 4: t = "CD-ROM"
        Case 5: t = "RAM Disk"
    End Select
    s = "Drive " & d.DriveLetter & ": - " & t
    MsgBox s
End Sub
 
Exactly what I was looking for! Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top