Calling the CD-Rom

Calling the CD-Rom

I would like to know how to call the CD-Rom, or rather search for its drive letter.

You can use the FileSystemObject (Microsoft Scripting Runtime in the references dialog). Iterate through the Drives collection of the FileSystemObject and check its DriveType property and DriveLetter property. DriveType 4 is the CD ROM.

Set a reference to the Microsoft Scripting Runtime and try this code.

Dim objFso As New FileSystemObjectDim objDrive As DriveFor Each objDrive In objFso.Drives    With objDrive        If .DriveType = CDRom Then            MsgBox "CD ROM is " & .DriveLetter        End If    End WithNext objDrive


Share the Post: