open a PDF with VBA

  • Thread starter Thread starter j
  • Start date Start date
J

j

I have a resume database with a field called PDF that stores the whole path
for the PDF of each resume. I would like to create a button on a form that
will open Acrobat Reader and the appropriate PDF. I thought this would be
simple enough but I cant seem to find an appropriate function in VBA. Can
someone point me in the right direction?

Thanks
 
Yes, it is simple enough: simply call Shell() in VBA by passing the full PDF
file name retrieved from the record. You need Adobe Reader installed, of
course.

Shell "C:\myPDFFolder\PDFFile.pdf"
 
j said:
The Shell functions seems to only work on exe files for me.

To use Shell, you'd have to pass both the Reader application's path and
the name of the file to be opened. However, assuming that Acrobat
Reader is registered as the application to open PDF files, you can
probably open the PDF file using Application.FollowHyperlink:

Application.FollowHyperlink "C:\myPDFFolder\PDFFile.pdf"

If that doesnt work, you can call the ShellExecute API, using the
fHandleFile function posted at:

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