Consulting

Results 1 to 4 of 4

Thread: Search PDF in ACtiveX VBA Help

  1. #1

    Search PDF in ACtiveX VBA Help

    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?

    Thanks!

  2. #2
    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.

    [VBA]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 [/VBA]
    Last edited by boneKrusher; 01-25-2006 at 10:39 AM.

  3. #3
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi there and welcome to VBAX

    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 form[VBA]Sub 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, ""

    AcroApp.Show
    AVDoc.FindText myString, 0, 0, 0

    End Sub[/VBA]If I turn anything else up I'll post back
    K :-)

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •