Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Open Acrobat PDF document from Access 2000

Status
Not open for further replies.

Ranvier

Programmer
Jun 17, 2004
73
GB
Hi,

I am developing an Access 2000 application and need the user to click on a command button that will open an acrobat pdf document (userGuide.pdf).

I have referenced the acrobat.tlb library file - can anyone provide me with some good VBA code that will simply open up the pdf file (userGuide.pdf) by opening up Acrobat on the users PC. Are there any other library files I have to include in my referencing? And does it matter what version of Acrobat the user is running? The location of the file is held in a variable 'CurrPath'.

Any help is appreciated.
Thanks
 
You can also insert a web borwser on the form and navigate the pdf file on that.
Also this link at google may help you

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
And what about simply the FollowHyperlink method ?
Application.FollowHyperlink CurrPath & "\userGuide.pdf"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Carva,

Heres the code I always use when opening external files from VB and it should also work in Access. It uses the windows API shellexecute which basicaly just tells windows to load the file with whatever program is associated with the extension (it's the same as typing something into the RUN box in windows).

#################################################
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
Const SW_NORMAL = 1
Const SW_HIDDEN = 2
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&



Public Function LoadExternalFile(Program As String, StartPath As String)
Dim Result, Message As String

Result = ShellExecute(0&, vbNullString, Program, vbNullString, StartPath, 1)
Select Case Result
Case SE_ERR_FNF
Message = "The specified file was not found"
Case SE_ERR_PNF
Message = "The specified path was not found"
Case SE_ERR_ACCESSDENIED
Message = "The operating system denied access to the specified file"
Case SE_ERR_OOM
Message = "The operating system is out of memory or resources"
Case SE_ERR_DLLNOTFOUND
Message = "The specified dynamic-link library was not found"
Case SE_ERR_SHARE
Message = "A sharing violation occurred, make sure no one else is using the file"
Case SE_ERR_ASSOCINCOMPLETE
Message = "The filename association is incomplete or invalid"
Case SE_ERR_DDETIMEOUT
Message = "The DDE transaction could not be completed because the request timed out"
Case SE_ERR_DDEFAIL
Message = "The DDE transaction failed"
Case SE_ERR_DDEBUSY
Message = "The DDE transaction could not be completed because other DDE transactions were being processed"
Case SE_ERR_NOASSOC
Message = "There is no application associated with " & Format(Right(Program, 3), ">") & " extensions"
Case ERROR_BAD_FORMAT
Message = "The EXE file is invalid (non-Win32 EXE or error in EXE image)"
End Select
If Result < 32 Then MsgBox Message, vbInformation + vbOKOnly, "Unable to Load File"
End Function
#################################################

Sindo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top