Computer Learning Zone CLZ Access Excel Word Windows

The best deal is the one that brings the most profit.

-2nd Rule of Acquisition
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Microsoft Access 308    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Open a PDF
Alex Hedley 
           
14 years ago
Hi Carl,

There are a couple of methods you could use.

How are your VBA skills?

1 is to create a button and add this code:

Dim strPath as String
strPath="C:\Path to the PDF document"
Application.FollowHyperLink strPath

You could replace strPath with a Field on your Form, it would have to contain the full path though.

Shorthand would be just
Application.FollowHyperlink "C:\path\FileToOpen.pdf"

--

Another option is using the Shell

strPath = "C:\path\FileToOpen.pdf"
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & strPath & Chr(34), 1, False

To be on the safe side I've added Chr(34) (which is "- double quotes) around the file name in case there are spaces in folder names, this causes issues and the Shell will stop at a space so won't find that full destination.

--

Another option is 'ShellExecute', add this to your Form's code:

Option Explicit
Option Compare Database
 
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
 
'(in the button click event you have chosen:)
 
Private Sub Command1_Click()

Dim strPath as String
strPath="C:\Path to the PDF document"

    ShellExecute 0, "Open", strPath, vbNullString, "C:\", SW_SHOWNORMAL
End Sub

Regards
Alex

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Microsoft Access 308.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/27/2026 1:28:33 AM. PLT: 0s