This does the default audio drive.
You can specify the drive letter like this:
Option Explicit
Private Declare Function mciSendString _
Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpstrCommand As
String, _
ByVal
lpstrReturnString As String, _
ByVal uReturnLength As
Long, _
ByVal hwndCallback As
Long) As Long
Sub OpenCDDrive(Optional strDriveLetter As String)
If Len(strDriveLetter) = 0 Then
mciSendString "Set CDAudio Door Open", 0&, 0, 0
Else
mciSendString "open " & strDriveLetter & _
": type CDAudio alias drive" & strDriveLetter, 0&, 0, 0
mciSendString "set drive" & strDriveLetter & " door open", 0&, 0, 0
End If
End Sub
Sub CloseCDDrive(Optional strDriveLetter As String)
If Len(strDriveLetter) = 0 Then
mciSendString "Set CDAudio Door Closed", 0&, 0, 0
Else
mciSendString "open " & strDriveLetter & _
": type CDAudio alias drive" & strDriveLetter, 0&, 0, 0
mciSendString "set drive" & strDriveLetter & " door closed", 0&, 0, 0
End If
End Sub
Sub test()
OpenCDDrive "D"
End Sub
RBS