Open a pdf file from code in my form

  • Thread starter Thread starter Tom Ross
  • Start date Start date
T

Tom Ross

Hi

I would like to open a pdf file when a user clicks on a field in my form

I can assemble the address for the file in code
"S:\procedures\manufacturing\x51-2.pdf" etc

How do I have that file opened in VBA Code.

Thanks

Tom
 
Tom Ross said:
Hi

I would like to open a pdf file when a user clicks on a field in my form

I can assemble the address for the file in code
"S:\procedures\manufacturing\x51-2.pdf" etc

How do I have that file opened in VBA Code.

Thanks

Tom
Hi Tommy,

Into forms there are controls, fields are only in queries and tables.

if you are able to put the name of the pdf file in a text box named f in
your form try this solution :

Dim ret As Integer
ret = Shell("rundll32.exe url.dll,FileProtocolHandler " & Me.f,
vbMaximizedFocus)

the second way that I can suggest you is the API shellExecute, but I think
that the previous way is more simply :

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_SHOWNORMAL = 1
MyPath=hereYourPath

ShellExecute Me.hWnd, "Open", Me.f, vbNullString, MyPath, SW_SHOWNORMAL

Ciao, Sandro
 
In addition to the other comments, which open PDFs in an outside process
(which means you may lose control of the program flow), if you are using
Acrobat Reader 4, there is an activeX control(pdf.ocx) which will work
inside an Access form. The activeX control is not included in later versions
of the Reader.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top