Open PDF in Form

bonekrusher

Registered User.
Local time
Today, 10:59
Joined
Nov 19, 2005
Messages
266
Thought this could be useful. The following code will open a PDF inside a form.

Insert the PDF activeX control and name it "viewer".
Make sure you add the Adobe OLE reference ("adobe"), if not the code will be undefined.

Code:
Private Sub Command18_Click()
Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim PDDoc As CAcroPDDoc
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AcroApp = CreateObject("AcroExch.App")
Set PDDoc = AVDoc.GetPDDoc
    
    
    Me.Viewer.loadFile ("C:\yourfile.pdf") 
    
End Sub
 
Here it is cleaned up...

Code:
Private Sub Command1_Click()

Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AcroApp = CreateObject("AcroExch.App")
   
    
Me.viewer.loadFile ("C:\yourfile.pdf")

End Sub
 
bonekrusher said:
Thought this could be useful. The following code will open a PDF inside a form.

Insert the PDF activeX control and name it "viewer".
Make sure you add the Adobe OLE reference ("adobe"), if not the code will be undefined.

Code:
Private Sub Command18_Click()
Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim PDDoc As CAcroPDDoc
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AcroApp = CreateObject("AcroExch.App")
Set PDDoc = AVDoc.GetPDDoc
    
    
    Me.Viewer.loadFile ("C:\yourfile.pdf") 
    
End Sub

How do you insert the PDF activeX control and name it "viewer" and add the Adobe OLE reference ("adobe")?

I've been looking and can't seem to find it anywhere that makes it work. This is exactly what I need for my database. Thanks for your help.
 
In the form design, click insert>ActiveX Control>Acrobat Adobe ActiveX Control.

Right Click on it>properties...change name to "viewer".

Depending on what version of acrobat you have the name of the ActiveX Control might be different.

If you need help more help, let me know what version of Access and Acrobat you are using.

Bones
 
I have Access 2010 and cannot find the activex control for my form. What is the name of this control for 2010?
 
Thanks for the replies. I actually forgot about this post for I think I found a work around for what I was trying to do back then.

However, I'm back in this same situation now and the code listed above gives me the error code "Active X component cant create object". ALL reference library reference have been added.

Your help would be greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom