Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open pdf file from Access (97/2000)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open pdf file from Access (97/2000)

    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>post 201988</post#> 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<pre>...exe ""C:Program FilesFirstClassDownloadRAD.pdf""")</pre>

    Regards,
    Hans

  3. #3
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open pdf file from Access (97/2000)

    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

  4. #4
    Lounger
    Join Date
    Apr 2001
    Location
    Khon Kaen, Thailand
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open pdf file from Access (97/2000)

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

    FollowHyperlink "C:Program FilesFirstClassDownloadRAD.pdf"

  5. #5
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open pdf file from Access (97/2000)

    Thanks Tim. I'll look at that also.

    Paul

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open pdf file from Access (97/2000)

    Paul, you asked
    <hr>Wherever did you come up with that?<hr>
    Well, by visiting Woody's Lounge of course <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. But there are many other useful sites too, for example Dev Ashish's Access Web.

  7. #7
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open pdf file from Access (97/2000)

    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

Posting Permissions

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