Opening a .pdf file from a VB6 .exe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shayne82609
    New Member
    • Nov 2008
    • 3

    Opening a .pdf file from a VB6 .exe

    Total noobie here, so spoon feed and speak slowly (and with code bytes) please.

    What I am trying to accomplish is a VB6 .exe menu program that will be set to autostart on a info CD. If you click on a button on the menu it will open a file from the CD. Easier said than done. The problem I ran into right off is Adobe Reader versions, directory differences, drive letter differences, etc...

    So I need the .exe to work without having to call anything by specific drive letter (C:\Program Files\Adobe\Rea der 9.0\Reader\Acro Rd32.exe is a perfect example. what if its a different version, location, drive)

    So far I seem to have the AcroRd32.exe problem solved (many thanks to bytes forum posters, all of you), but am still hung up on calling up the actual .pdf file without using drive letters.

    This is what I have so far:

    Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    Private Sub Command1_Click( )
    ShellExecute 0&, "OPEN", "X:\Files\broch ure.pdf", "", "", 1
    End Sub

    This works well so far, but still relies on a drive letter.

    The .exe file would be placed on X:\ following the above example, and the supporting files (brochure.pdf in this case) would be in a hidden subfolder X:\Files\

    Any input is greatly appreciated.
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    Because .exe file will be in X:\ dir and .pdf file in X:\Files\ dir so try using this in your command (in place of X:\Files\xxx.pd f) :

    ShellExecute 0&, "OPEN", App.path & "\Files\" & "xxx.pdf", "", "", 1

    Hope it will solve your problem. Do acknowledge it.

    Comment

    • Shayne82609
      New Member
      • Nov 2008
      • 3

      #3
      Originally posted by smartchap
      Because .exe file will be in X:\ dir and .pdf file in X:\Files\ dir so try using this in your command (in place of X:\Files\xxx.pd f) :

      ShellExecute 0&, "OPEN", App.path & "\Files\" & "xxx.pdf", "", "", 1

      Hope it will solve your problem. Do acknowledge it.

      Thank you for the reply smartchap. That works perfectly. If there is anyone else interested in doing the entire code is below. Cut and Paste at will.

      1. Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

      2. Private Sub Command1_Click( )
      3. ShellExecute 0&, "OPEN", App.Path & "\Files\" & "brochure.p df", "", "", 1
      4. End Sub

      Comment

      Working...