Results 1 to 5 of 5

Thread: code to run file from user's CD drive

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    29

    code to run file from user's CD drive

    I have an Excel file and iview32.exe I am going to put on a CD.

    I use this code to find what drive user utilizes (and it works):

    DriveID = Application.ActiveWorkbook.Path

    While testing from my HD, I have this code to activate iview32.exe (and it works):

    Shell "D:/Program Files\Irfanview\i_view32.exe /slideshow=C:\a.txt", vbNormalFocus

    After I put all on CD, I will need to modify above to reflect path on CD like so:

    Shell DriveID (User's CD Drive)& ":" & "\" (Concatenate this)Irfanview\iview32.exe /slideshow=C:\a.txt", vbNormalFocus (Path on CD)

    Tried it, but can't get parens () and Quotes " and & in right places.

  2. #2
    Addicted Member aldinator's Avatar
    Join Date
    May 2002
    Location
    Canada - better than all the rest!
    Posts
    216
    i don't know if this is right but here goes nothing

    DriveID = Application.ActiveWorkbook.Path

    Shell DriveID & ":\Irfanview\iview32.exe /slideshow=C:\a.txt", vbNormalFocus

  3. #3
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    This will show you all available cd-rom drives. Adopt it to your code.
    VB Code:
    1. Private Declare Function GetDriveType Lib "kernel32" _
    2. Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
    3.  
    4. Private Sub Command1_Click()
    5. Dim drive
    6.     For i = 65 To 90
    7.         drive = Chr(i) & ":\"
    8.         If GetDriveType(drive) = 5 Then MsgBox "CD-ROM Found! Drive - " & drive
    9.     Next i
    10. End Sub

  4. #4
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    This just for fun. You may need it:

    VB Code:
    1. Private Declare Function mciSendString Lib "winmm.dll" _
    2. Alias "mciSendStringA" (ByVal lpstrCommand As String, _
    3. ByVal lpstrReturnString As String, ByVal uReturnLength As Long, _
    4. ByVal hwndCallback As Long) As Long
    5.  
    6. Private Sub cmdCloseCupHolder_Click()
    7.     mciSendString "set CDAudio door closed", 0, 127, 0
    8. End Sub
    9.  
    10. Private Sub cmdOpenCupHolder_Click()
    11.     mciSendString "set CDAudio door open", 0, 127, 0
    12. End Sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    29
    Aldinator:

    I tried your suggestion and it worked like a charm!
    Thanks to all who responded

Posting Permissions

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



Click Here to Expand Forum to Full Width