Open PDF inside Access Form

C

Christofer Dutz

Hi,

I am workin on a small Database which manages a collection of
PDF-Documents. I managed to Open a PDF using the folowing code.

Private Sub openPdf(Path As String)
Dim AcroApp As Object
Dim PDDoc As Object
Dim avDoc As Object

Set AcroApp = CreateObject("AcroExch.App")
Set PDDoc = CreateObject("AcroExch.PDDoc")

If PDDoc.Open(Path) Then
AcroApp.show
Set avDoc = PDDoc.OpenAVDoc("")
Else
MsgBox "Unable to open the PDF-file", vbInformation
End If

Set avDoc = Nothing
Set PDDoc = Nothing
Set AcroApp = Nothing
End Sub

Unfortunately I want to insert the PDF inside a form. Just the way it
looks if you view a PDF inside the Internet-Explorer. This opens the
Accrobat Reader as a separate application.

Christofer
 
A

Arvin Meyer

If you can locate a copy of Acrobat 4.x, there is an ActiveX control that
performs the work of the Acrobat reader. It is named pdf.ocx. If you can
register that control, you can put it in an Access form and it will allow
you to open the pdf inside the Access form.

Failing that, you may want to associate the pdf's with IE and use them as an
IE plug-in. There is a web-browser control which works the same way in an
Access form.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
C

Christofer Dutz

Arvin said:
If you can locate a copy of Acrobat 4.x, there is an ActiveX control that
performs the work of the Acrobat reader. It is named pdf.ocx. If you can
register that control, you can put it in an Access form and it will allow
you to open the pdf inside the Access form.
Unfortunately my customer is not allowed/able to change/install any
software. So I am not able to use this version.
Failing that, you may want to associate the pdf's with IE and use them as an
IE plug-in. There is a web-browser control which works the same way in an
Access form.
Mabe I don't have to associate the PDF with the IE becase simply using
it to view a url to the PDF should work ... thanks for this tip. Is sort
of crazy but I'm used to doing crazy things all the time when doing
simple tasks with Access ;)

Tanks again ... I'll try this.

Chris
 
A

Arvin Meyer

Mabe I don't have to associate the PDF with the IE becase simply using
it to view a url to the PDF should work ... thanks for this tip. Is sort
of crazy but I'm used to doing crazy things all the time when doing
simple tasks with Access ;)

I just tried it with the Web Browser control and it works fine. Here's some
sample code because it isn't apparent how to use the navigate method:

Private Sub cmdNavigate_Click()
If Not IsNull(Me.txtURL) Then
With Me.ActiveXCtl0
.Navigate Me.txtURL
End With
End If
End Sub

cmdNavigate is a button which is using the path in txtURL as a hyperlink
substitute. If you put the full path to the pdf file in txtURL it will open
it within the Access form's IE control.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
C

Christofer Dutz

After looking at the additional controls installed on my test system I
found a AccrobatReader Control after updating to a 5.x version of the
Accrobat reader. I used this and everything was fine.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top