Gary
I actually got this to work, but was unhappy with the outcome. It turned out
that with my solution there were some limitations I could not live with.
First, this method requires the FULL Acrobat product.
Second, it took a good 5 to 10 seconds for the form to load on the
average PC.
Below is a solution I tested and had working, abet the limitations above.
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 (make its name sfrmForm2) on
it that uses the first form as its Source Object. Add a list box control
(make its name lstFiles) whose row source is the unambiguous pathname to a
few PDF files. In the Code module of this form go into Tools References and
make a reference to the "Adobe Acrobat X.0 Type Library" (where the X is a
number 4,5, or 6), then add the following code
Option Compare Database
Option Explicit
Dim AcroExchAVDoc As CAcroAVDoc
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
On Error Resume Next ' if is already closed Blow past
error
AcroExchAVDoc.Close (False)
' Add another error handler here
blnOK = AcroExchAVDoc.OpenInWindowEx(lstFiles.Value, _
sfrmForm2.Form.Hwnd, AV_DOC_VIEW, True, 0, _
PDUseBookmarks, AVZoomFitWidth, 0, 0, 0)
If Not blnOK Then
MsgBox "Can't open file: " & lstFiles.Value
End If
End Sub
In a REAL application you are gonna have to have MUCH better error handling
that I have in this stripped down example. Especially since there is so
much that can go wrong with this. Also you better be prepared for a form
that takes forever to open. Instantiating the Acrobat Document object can
take quite a bit of time. And lastly I am just about positive that you will
HAVE to have the FULL Acrobat PDF product on the machine to run this code. I
do not think this will work with the free reader.
Well there you have it, I wish you luck. Perhaps this will inspire one or
two of the really smart guys out there to come up with a better way to do
this.
Ron W