By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

Access/Acrobat PDF Viewer

P: 18
I have an access database which has some text box as for input search citeria and a continous subform to display the search result.
Pls teach me in steps how to add a viewer (or active x control element) to see the corresponding pdf file link to the record.
Suppose the records in the ProjectRecord Form and has a field called imagelink which have the path of the pdf file.
Wish to have the code shown.
Thanks!
Feb 26 '08 #1
Share this Question
Share on Google+
7 Replies


Expert 100+
P: 446
Hi
Assuming you have a command button called Command1 and can read the path and file name of the PDF document from a TextBox you will need something like this on the Click event.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Command1_Click()
  3. On Error GoTo Err_Command1_Click
  4.     Dim stAppName As String
  5.     Dim stPathFileName As String
  6.  
  7.     'Define path and file name of PDF document, keep .pdf extention
  8.     stPathFileName = Me!txtPathFile
  9.     stAppName = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe " & stPathFileName
  10.     Call Shell(stAppName, 1)
  11.  
  12. Exit_Command1_Click:
  13.     Exit Sub 
  14. Err_Command1_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_Command1_Click
  17.  
  18. End Sub
  19.  
This obviously depends where your Acrobat reader file is located

S7
Feb 26 '08 #2

P: 18
If I have to add the active x for pdf file at the main form to display the first row of record at the subform, can it be done? or I have to click the row of record at the subform then display the corresponding pdf at the active x display? (The subform consists of a row of scroll down text boxes...)
How to do that in steps?
Besides, will it be a lot of acrobat buttons occupy the screen when I use the active x to open the pdf file at the main form? Can I control that just like for the tiff and jpg viewer (just picture and no other button eg zoom...etc.)?
For time being, I think I will need:
1. add the active x at the main form
2. I may need a code to add the text boxes (may be for the click event)...
3...
then I dont know how to make the code and also how to make the active x know how to display the corresponding pdf file when the user scroll down the subform or click the text box at the subform.
Hope that you can understand and really looking for any kindly help!
Thanks once again!
Feb 27 '08 #3

Expert 100+
P: 446
Hi Jo

The code I showed in my last post was to start-up Adobe Acrobat in a separate window and automatically display the document specified in the Path. I thought it best to associate a command button with each record and then click to display the document as needed. This works.

I was not using ActiveX components and not trying to display the document inside a window/box/control on a form. My assumption being that a PDF file would be trying to show one or more A4/Letter size pages which would not be easy to read in a small window.

I'm sure there may well be ActiveX products that can be added into Access to allow displaying PDF's in an 'Image Control'; I've never needed to look for one, but I would expect instructions how to use it to be provided by the software supplier.

I will look into this further and am currently checking AcroPDF.dll
S7
Feb 27 '08 #4

P: 18
Thanks for the previous suggestion!
I have add a preview button at the subform and insert a OLE1 object at the main form call ProjectDrawingForm.

Private Sub Preview_Click()
OLE1.Class = "Adobe Acrobat 7.0"
OLE1.OLETypeAllowed = acOLELinkedOLE1.SourceDoc = "C:\xnview\" & Form![Text 14].value &".pdf
OLE1.Action = acOLECreateLink
OLE1.SizeMode = acOLESizeZoom
End Sub

(change to following)
Private Sub Preview_Click()
Form_ProjectDrawingForm.OLE1.Class = "Adobe Acrobat 7.0"
Form_ProjectDrawingForm.OLE1.OLETypeAllowed = acOLELinked
Form_ProjectDrawingForm.OLE1.SourceDoc = "G:\AsBuilt\C\C001\1135_0A.pdf"
Form_ProjectDrawingForm.OLE1.Action = acOLECreateLink
Form_ProjectDrawingForm.OLE1.SizeMode = acOLESizeZoom
End Sub

why the OLE1.Action cannot work ?
Besides,for the SourceDoc, such as Form_ProjectDrawingForm.OLE1.SourceDoc = "G:\AsBuilt\C\C001\1135_0A.pdf" the source "G:\AsBuilt\C\C001\1135_0A.pdf"should be extract from the table ProjtectDrawingRecord and inside a field called ImageLink
But need to change as
(original field look like):> file:\\G:\AsBuilt\C\C001\1135_0A.pdf
(so I need to extract the info look like):>G:\AsBuilt\C\C001\1135_0A.pdf
what will be the code look like for such function?
Thanks a lot!
Mar 4 '08 #5

FishVal
Expert 2.5K+
P: 2,653
As an additional option you may try WebBrowser ActiveX control on your form.
Using its Navigate method smoothly populates it with an external pdf file.
Acrobat ActiveX control usually makes troubles.

Regards,
Fish
Mar 4 '08 #6

P: 18
I have sucessfully added the OLE bounded object at the main form.
The OLE will display the pdf file when the preview button at the subform is clicked with the following codes:

Private Sub Preview_Click()
Form_ProjectDrawingForm.OLE1.Class = "Adobe Acrobat 7.0"
Form_ProjectDrawingForm.OLE1.OLETypeAllowed = acOLELinked
Form_ProjectDrawingForm.OLE1.SourceDoc = Me!ImageLink.Value
Form_ProjectDrawingForm.OLE1.Action = acOLECreateLink
Form_ProjectDrawingForm.OLE1.SizeMode = acOLESizeZoom
End Sub

I have problem here:
1. what will be the code change if the value Me!ImageLink.Value (the value is in fact the full path of the pdf file e.g. g:\abc\abc.pdf) is empty or the path is wrong or the file is not exists and let the OLE object display back as a blank white?
2. in fact, there is a reset button in the main form, what code I should add so that the OLE object can reset to blank.
Thanks!
Mar 5 '08 #7

Expert 100+
P: 446
Hi

This looks interesting and I must try it when I get time!

If it works as well as it sounds I would be tempted to have an extra PDF file in the system bearing text saying "Document Not Available" and display that file if
Me!ImageLink.Value was Null, thereby avoiding the problem of an empty OLE control.

S7
Mar 6 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.