Opening a pdf with VBA in MS Access

R

Rich

I have a table in Access which contains a filepath and filename to open
either word or pdf documents. I use the following code (which works fine) to
open word documents:

Set oApp = CreateObject("Word.Application")
oApp.Visible = True
oApp.Documents.Open filepath & "\" & filename

I want to be able to use some similar code to open a pdf document. There
will be several users of this database. All will have acrobat but I cannot
guarantee it will be located in exactly the same place so I need something
that works similar to the above coding which is universal.

Anyone?

Rich
 
A

Allen Browne

Try:
FollowHyperlink filepath & "\" & filename

That should open the document in whatever program is registered to handle it
on the user's computer, e.g. Acrobat Reader for pdf, or Word of doc.
 
C

chris.nebinger

I have a table in Access which contains a filepath and filename to open
either word or pdf documents.  I use the following code (which works fine) to
open word documents:

    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True
    oApp.Documents.Open filepath & "\" & filename

I  want to be able to use some similar code to open a pdf document.  There
will be several users of this database.  All will have acrobat but I cannot
guarantee it will be located in exactly the same place so I need something
that works similar to the above coding which is universal.

Anyone?

Rich


Rich,

The answer to your question will be found here:

http://www.mvps.org/access/api/api0018.htm


Chris Nebinger
 
F

Fluit

Try:
    FollowHyperlink filepath & "\" & filename

That should open the document in whatever program is registered to handle it
on the user's computer, e.g. Acrobat Reader for pdf, or Word of doc.

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.








- Show quoted text -

I've noticed sometimes problems with using "followhyperlink".
an alternative is
Shell strPDFReader & " " & strFilenaam, vbMaximizedFocus


regards
Patrick
 
F

Fluit

I have a table in Access which contains a filepath and filename to open
either word or pdf documents.  I use the following code (which works fine) to
open word documents:

    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True
    oApp.Documents.Open filepath & "\" & filename

I  want to be able to use some similar code to open a pdf document.  There
will be several users of this database.  All will have acrobat but I cannot
guarantee it will be located in exactly the same place so I need something
that works similar to the above coding which is universal.

Anyone?

Rich
 
D

Douglas J. Steele

I've noticed sometimes problems with using "followhyperlink".
an alternative is
Shell strPDFReader & " " & strFilenaam, vbMaximizedFocus


That won't work properly if strPDFReader or strFilenaam contain spaces. It
should be

Shell """" & strPDFReader & """ """ & strFilenaam & """",
vbMaximizedFocus

That having been said, I've never had a problem with FollowHyperlink.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top