PC Review


Reply
Thread Tools Rate Thread

Can VBA issue a command to eject a CD?

 
 
Don Wiss
Guest
Posts: n/a
 
      4th Mar 2007
I have a VBA program that reads a file created from a DVD/CD. I then by
hand eject the disc. Can VBA issue a command to eject the disc?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      4th Mar 2007
Try 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()

mciSendString "Set CDAudio Door Open", 0&, 0, 0

End Sub


Sub CloseCDDrive()

mciSendString "Set CDAudio Door Closed", 0&, 0, 0

End Sub


RBS



"Don Wiss" <donwiss@no_spam.com> wrote in message
news:(E-Mail Removed)...
>I have a VBA program that reads a file created from a DVD/CD. I then by
> hand eject the disc. Can VBA issue a command to eject the disc?
>
> Don <www.donwiss.com> (e-mail link at home page bottom).


 
Reply With Quote
 
Don Wiss
Guest
Posts: n/a
 
      4th Mar 2007
Where are you setting which drive to open/close?

On Sun, 4 Mar 2007 22:12:37 -0000, "RB Smissaert"
<(E-Mail Removed)> wrote:

>Try 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()
>
> mciSendString "Set CDAudio Door Open", 0&, 0, 0
>
>End Sub
>
>
>Sub CloseCDDrive()
>
> mciSendString "Set CDAudio Door Closed", 0&, 0, 0
>
>End Sub
>
>
>RBS
>
>
>
>"Don Wiss" <donwiss@no_spam.com> wrote in message
>news:(E-Mail Removed)...
>>I have a VBA program that reads a file created from a DVD/CD. I then by
>> hand eject the disc. Can VBA issue a command to eject the disc?
>>
>> Don <www.donwiss.com> (e-mail link at home page bottom).


 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      5th Mar 2007
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


"Don Wiss" <donwiss@no_spam.com> wrote in message
news:(E-Mail Removed)...
> Where are you setting which drive to open/close?
>
> On Sun, 4 Mar 2007 22:12:37 -0000, "RB Smissaert"
> <(E-Mail Removed)> wrote:
>
>>Try 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()
>>
>> mciSendString "Set CDAudio Door Open", 0&, 0, 0
>>
>>End Sub
>>
>>
>>Sub CloseCDDrive()
>>
>> mciSendString "Set CDAudio Door Closed", 0&, 0, 0
>>
>>End Sub
>>
>>
>>RBS
>>
>>
>>
>>"Don Wiss" <donwiss@no_spam.com> wrote in message
>>news:(E-Mail Removed)...
>>>I have a VBA program that reads a file created from a DVD/CD. I then by
>>> hand eject the disc. Can VBA issue a command to eject the disc?
>>>
>>> Don <www.donwiss.com> (e-mail link at home page bottom).

>


 
Reply With Quote
 
Don Wiss
Guest
Posts: n/a
 
      5th Mar 2007
On Mon, 5 Mar 2007, RB Smissaert <(E-Mail Removed)> wrote:

>This does the default audio drive.
>You can specify the drive letter like this:


Thanks. It works like a charm. I'm not sure what is considered the default.
One reads CDs/DVDs and is called "J". The other read/writes CDs/DVDs and is
called "D". I would consider the one that reads only the default.

As I've added hard drives the letters have become scrambled and I haven't
bothered to change them.

Don <www.donwiss.com> (e-mail link at home page bottom).
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      5th Mar 2007
You probably won't need it, but there are lots of other
commands you can pass to this API.

RBS


"Don Wiss" <donwiss@no_spam.com> wrote in message
news:(E-Mail Removed)...
> On Mon, 5 Mar 2007, RB Smissaert <(E-Mail Removed)> wrote:
>
>>This does the default audio drive.
>>You can specify the drive letter like this:

>
> Thanks. It works like a charm. I'm not sure what is considered the
> default.
> One reads CDs/DVDs and is called "J". The other read/writes CDs/DVDs and
> is
> called "D". I would consider the one that reads only the default.
>
> As I've added hard drives the letters have become scrambled and I haven't
> bothered to change them.
>
> Don <www.donwiss.com> (e-mail link at home page bottom).


 
Reply With Quote
 
Don Wiss
Guest
Posts: n/a
 
      5th Mar 2007
On Mon, 5 Mar 2007, RB Smissaert <(E-Mail Removed)> wrote:

>You probably won't need it, but there are lots of other
>commands you can pass to this API.


Where are they documented?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      5th Mar 2007
Here is one:
http://www.geocities.com/smigman.geo/mci/riffmci.html

RBS

"Don Wiss" <donwiss@no_spam.com> wrote in message
news:(E-Mail Removed)...
> On Mon, 5 Mar 2007, RB Smissaert <(E-Mail Removed)> wrote:
>
>>You probably won't need it, but there are lots of other
>>commands you can pass to this API.

>
> Where are they documented?
>
> Don <www.donwiss.com> (e-mail link at home page bottom).


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tape Eject command using RSM eject CLarke Windows XP General 0 10th Jul 2008 06:21 AM
ntbackup rsm eject command =?Utf-8?B?Q2h1Y2tX?= Microsoft Windows 2000 5 4th Feb 2006 10:27 AM
Command to Eject Tape Alan Tang Microsoft Windows 2000 CMD Promt 3 23rd Aug 2004 03:28 PM
eject command =?Utf-8?B?d2ViaXRlY3Q=?= Microsoft Windows 2000 2 8th Aug 2004 07:33 AM
CD-ROM Eject Command Robert Johnson Windows XP New Users 5 22nd Oct 2003 06:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:27 PM.