• Open pdf file from Access (97/2000)

    Author
    Topic
    #380861

    I’m trying to use the Shell command to open a pdf file on my c drive. This is what I’m using.
    Dim retVal
    retVal = Shell(“C:Program FilesAdobeAcrobat 4.0ReaderAcroRd32.exe””C:Program FilesFirstClassDownloadRAD.pdf”)

    I’m getting a message “There was an error opening this document”.
    The message isn’t always the same. The .exe by itself opens fine. It’s when I add the file that it errors out. Anyone tell me how I can open a .pdf file from Access.

    Thanks
    Paul

    Viewing 0 reply threads
    Author
    Replies
    • #639496

      I would suggest using the ShellExecute function to open .pdf files. ShellExecute with an “Open” argument is equivalent to opening a file from Windows Explorer; you don’t have to specify the name and path of the application; Windows figures this out for you. So if a user has a different version of the Acrobat reader, or has installed it in a different location, the .pdf file will still open. See post 201988 for instructions on how to use ShellExecute.

      If you’d rather use Shell, insert a space after .exe and two double quotes after .pdf, so that the last part of the line reads

      ...exe ""C:Program FilesFirstClassDownloadRAD.pdf""")

      Regards,
      Hans

      • #639513

        Hans I can’t even begin to imagine how long it would have taken me to figure out the syntax for this. Wherever did you come up with that? Thanks very much, I will give the customer the choice of which method they want to use and pass your solution on to a few other people as well.

        Paul

        • #639516

          You can also use the FollowHyperlink method to open a given file.

          FollowHyperlink “C:Program FilesFirstClassDownloadRAD.pdf”

        • #639525

          Paul, you asked[indent]


          Wherever did you come up with that?


          [/indent]Well, by visiting Woody’s Lounge of course grin. But there are many other useful sites too, for example Dev Ashish’s Access Web.

          • #639549

            Point well said. What bothers me is that to open Word or Excel you simply need the normal Paths as Strings syntax. You don’t need a space between .exe and ” and you don’t need the extra “”. I had checked out Dev’s site and didn’t see anything and tried searching on pdf in this form and another one and didn’t see anything(I hate not being able to come up with the solution). That syntax was new to me and I’m no Spring Chicken.
            Thanks again.

            Paul

    Viewing 0 reply threads
    Reply To: Open pdf file from Access (97/2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: