Creating a path and opening a PDF File

  • Thread starter Thread starter Chez
  • Start date Start date
C

Chez

I have PDF files saved on our server that relate to each record in my
database. I'm trying to create a command button that will create a path to
these files and do one of two things.

1. Create the path and open the PDF file in Acrobat Reader.
OR
2. Create the path and display a particular PDF file within a Form.

I'd prefer to do option #2. I can currently do option #2 with an image
using the following code below.

Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String

On Error Resume Next
strMDBPath = CurrentProject.FullName

intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))

strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName

Me.imageframe.Picture = strImagePath

PLEASE HELP
 
For option 1., use the application.followhyperlink method. Try something like:

Dim strPDFPath As String

On Error Resume Next

strPDFPath = CurrentProject.Path & "\" & Me.txtPDFName

Application.FollowHyperlink strPDFPath
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
I don't believe it's possible to display the PDF within a form anymore: it's
been years since Adobe supported the ActiveX control to display PDFs.

To open the file in Acrobat Reader (or whatever program has been associated
with the PDF extension on the user's machine), use

Application.FollowHyperlink strImagePath
 
Back
Top