Display .tif and .pdf in Form

G

Giovanne

Hi all,

I've read many posts from people looking to open a .pdf or .tif from
Access...however, I'm trying to view the .pdf or .tif in the form so that I
may enter information from the .pdf or .tif into fields on the form.
Obviously, I can open the applications by using the follow hyperlink command,
however, once open, I have to re-size the windows which takes time. So,
anyone know of a way to do this?

Thanks!
 
R

Ron Weiner

I did a solution for the PDF part of this a while ago, BUT this solution
REQUIRES the Full version of Adobe Acrobat be installed on the machine. For
me this was not an Issue.

Here is how I did it:

Create a new form and save it. This form gets no controls or code. We are
only gonna' use it as a container to display our PDF's.

Create another form and put a Subform Control on it that uses the form you
just saved as its Source Object. Make the name of the Subform CONTROL
sfrmForm2 Next add a list box control whose name is lstFiles. Set the Row
Source of the list box to unambiguous Filenames of a few PDF files somewhere
on your hard Drive. My Row Source was set thusly.
"c:\Inv83597.pdf";"c:\Inv83598.pdf";"c:\Inv83599_AOCR.pdf";"c:\rw_aocred.pdf
";"c:\test_ocred.pdf"


Add the following code to the Main form.

Option Compare Database
Option Explicit
Dim OffSetX As Long, OffSetY As Long
Dim AcroExchAVDoc As Object

Private Sub Form_Load()
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set AcroExchAVDoc = Nothing
End Sub

Private Sub lstFiles_Click()
Dim blnOK As Boolean
Const AV_DOC_VIEW = 2
Const PDUseBookmarks = 3
Const AVZoomFitWidth = 2

' Open the selected file
On Error Resume Next ' if is already closed Blow past
error
AcroExchAVDoc.Close (False)

' Add your real Error handler here to catch any errors from here

blnOK = AcroExchAVDoc.OpenInWindowEx(lstFiles.Value, _
sfrmPDF.Form.hwnd, AV_DOC_VIEW, True, 0, _
PDUseBookmarks, AVZoomFitWidth, 0, 0, 0)
' See IAC.bas and the Acrobat Viewer IAC
' Overview for information on the
' OpenInWindowEx open modes
AcroExchAVDoc.SetViewMode 1
' Force a repaint to slow down the action
' so the combo does not get ahead
' of the form causing a crash when the
' Up or Down arrow us held down
sfrmPDF.Form.Repaint
If Not blnOK Then
MsgBox "Can't open file: " & lstFiles.Value
End If
End Sub

This is BARE BONES demonstration only code that simply opens the PDF in the
subform and allows the user to page through it. In real life you will need
to be able to handle a whole host of possible errors, resizing issues, menu
issues, etc. If you decide to go with a solution like this be sure to
download the Adobe Viewer IAC overview PDF (available from
http://www.adobe.com/support/main.html) for a whole bunch of stuff you can
do with the insides of a PDF.

Good Luck.

Ron W
 
A

Arvin Meyer

Adobe used to have an ActiveX control named pdf.ocx that did this perfectly.
They broke that functionality in version 5.0. If you happen to have a copy
of Acrobat Reader before 4.05, you can install it and then you can add the
control into an Access form and it will work.

A little more trouble is to use a Microsft Web Browser control in an Access
form. Later versions of Acrobat Reader come as a plug-in to IE. So just put
the IE control in the form and add a textbox (Text1) to hold the code. Now
use the double-click event of the textbox, or a command button to execute
the following code:

Me.WebBrowserControlName.Navigate Me.Text1

Don't look for any methods in Intellisense. But you can find them in the
Object Browser if you have the library loaded.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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