View Full Version : Search PDF in ACtiveX VBA Help

01-24-2006, 09:48 AM
Hi All,

I have a MS Access form which has an PDF ActiveX to view PDF's. I want to be able to search the PDF from within Access using VBA. Does any one know how to do this?


01-25-2006, 09:31 AM
Here is a little more information:

I have a PDF ActiveX called "Viewer" on a form. When the user clicks the button, it brings the PDF up. This works great. I would like to beable to search the PDF. Here is the Code that I am using. Any help would be great.

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:\temp\mom.pdf")
AVDoc.FindText ("portal"), 0, 0, 0 ' this line doesnt return anything??
End Sub

01-26-2006, 05:21 AM
Hi there and welcome to VBAX :hi:

The problem here is that the ActiveX control (the viewer on the form) does not expose the kind of functionality you want.
The AcroApp, and related objects are created as separate objects from the viewer from a different type library (Acrobat.tlb) so the two are not linked in any way.
I guess there are three options:
1) try and get hold of the instance of Acrobat that is created when the ActiveX control open a file, set that as your CAcroApp object, get the open document and use that. I haven't had much success in trying this approach as yet.
2) there may be an 3rd party form control available that does allow more access to the app/document
3) just run an instance of Acrobat reader instead of the having it on the formSub FindTextInPDF()

Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim myPath As String
Dim myString As String

'you'll need to change these strings
myPath = "C:\temp\Excel2003ObjectModel.pdf"
myString = "object"

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

AVDoc.Open myPath, ""

AVDoc.FindText myString, 0, 0, 0

End SubIf I turn anything else up I'll post back

01-26-2006, 06:05 AM
Thanks Killian,

Currently I am running Acrobat outside the form and your codes works great. I did find "PDFviewer", a third party which does what I need in side a form.

I refuse to give up on Adobe.OCX. I have been trying option 1 for over a week. Its a challenge right now. I will not let it kick my butt! I've seen Acrobat.ocx in IE with a search box, so I bet there is a way. Are there anybooks that can help me?

Can't thank you enough for your time and help.

Thank you!

I'll keep searching.