Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 32

Thread: Open/Close CD Drive using VBA

  1. #1

    Open/Close CD Drive using VBA



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Can you use VBA to open and close the CD Drive?

  2. #2
    Administrator Simon Lloyd's Avatar
    Join Date
    Apr 2011
    Location
    Manchester, England
    Posts
    324
    Articles
    0
    Kind regards,
    Simon Lloyd
    Microsoft Office Discussion

  3. #3
    Thanks very much Simon, but, can i bother you to PDF the page and attach it here for me please? The internet policies here are pretty strict, and i cannot access that website.

    Your help is appreciated.

  4. #4
    Administrator Simon Lloyd's Avatar
    Join Date
    Apr 2011
    Location
    Manchester, England
    Posts
    324
    Articles
    0
    There aren't any restrictions accessing that site, i work at a large corporate with a very strict firewall and can access it and all content, its a forum run on exactly the same software as this.
    Kind regards,
    Simon Lloyd
    Microsoft Office Discussion

  5. #5
    Well, I obviously don't work at the same place as you then! All URLs are on the blacklist unless they are whitelisted, if you can see what i mean (and it takes quite a while to get a site whitelisted). But anyway, maybe i can get it some other way.

  6. #6
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    I wonder who got my site whitelisted? (Tell them they should be adding Simon's too.)

    Here's another version of the CD code too...

    Code:
    Private Declare Sub SendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, _
    ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, _
    ByVal hwndCallback As Long)
    
    Sub OpenCDTray()
        SendStringA "Set CDAudio Door Open", 0&, 0, 0
    End Sub
    
    Sub CloseCDTray()
       SendStringA "Set CDAudio Door Closed", 0&, 0, 0
    End Sub
    Simon's version is nicer though.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  7. #7
    Quote Originally Posted by Ken Puls View Post
    Simon's version is nicer though.
    I managed to get hold of it

    Any tips on making it work with 64 bit? i get "The code in this project must be updated for use on 64-bit systems. Please review and update Declare Statements and then mark them with the PtrSafe attribute"

  8. #8
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    What version of Excel and of Windows are you running?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  9. #9
    Win 7 Pro 6.1.7601 64-Bit
    Office 2010

  10. #10
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    Right, but is your Office 32 or 64 bit. I'm guessing 32bit, but just want to be sure.

    I have to run out, but I'll look at this one later tonight my time.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Page 1 of 4 1 2 3 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •