View Full Version : How to open a pdf file by using the access form


usmani_global
06-05-2008, 03:59 AM
Dear Sir

Our company is involved in customs clearance. we often use to search/view the pdf files in various range. the question is that how can i open a pdf file in access form
for example i have a pdf file namely "12-05-08" in "rate sheet" folder in my document. If i design a form in which there is a combo box showing all the files in that specific folder, How can i view this file by clicking preview report.

Kiwiman
06-05-2008, 10:44 AM
Howzit

This works for me - I have this code that opens any document I have tried to date (Excel, Word, PDF, txt) which is the code on a command button on a form


Private Sub cmdView1_Click()
Call OpenDocument(Me.Attach1) ' Me.Attach1 holds the file pathname
End Sub


The code below is a module that is called from the form wanting to view the file

Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

matsuir
06-05-2008, 10:51 AM
U can hyperlink it

Daveyk01
06-11-2008, 01:56 PM
Howzit

This works for me - I have this code that opens any document I have tried to date (Excel, Word, PDF, txt) which is the code on a command button on a form


Private Sub cmdView1_Click()
Call OpenDocument(Me.Attach1) ' Me.Attach1 holds the file pathname
End Sub


The code below is a module that is called from the form wanting to view the file

Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

Fantastic Tip!!!

forman
08-04-2008, 08:28 AM
Hi Kiwiman

Can you clarify where the two pieces of code sholud be, I'm assuming that the first code is attached to the 'On Click' of the button, but I'm stuck on the second piece of code.

Thanks

Alan

Daveyk01
08-04-2008, 09:15 AM
Hi Kiwiman

Can you clarify where the two pieces of code sholud be, I'm assuming that the first code is attached to the 'On Click' of the button, but I'm stuck on the second piece of code.

Thanks

Alan

I put it in a support module that has a while bunch of other pulic functions and subs.

forman
08-05-2008, 05:04 AM
Thanks for that, going to play with it now

Alan

gbuckton
09-05-2008, 01:07 PM
Howzit

This works for me - I have this code that opens any document I have tried to date (Excel, Word, PDF, txt) which is the code on a command button on a form


Private Sub cmdView1_Click()
Call OpenDocument(Me.Attach1) ' Me.Attach1 holds the file pathname
End Sub
The code below is a module that is called from the form wanting to view the file

Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

Can someone please tell me where the 'Me.Attach1' code should go, and what it should look like?

I'm guessing its something like:

Me.Attach1 = C:\folder\docname.pdf

thanks,

gbuckton
09-06-2008, 09:39 AM
Just as an FYI, I've found a solution for this - by placing the code 'Application.Followhyperlink "C:\folder\docname.pdf" on the OnClick event...

thanks,