1 Reply Latest reply: Aug 27, 2014 7:34 AM by Bernd Alheit RSS

    find an highlight text with Excel vba an Acobat XI Pro

    AxelAhrens Community Member

      Hello,

       

      i want to write a VBA Script to search for and highlight text.

       

      Until now my Script open the PDF and search for text. But how can i highlight it ?

       

      Thank you.

       

      Axel

       

      My Code :

       

      Sub OpenPDFPageView()

         

         

          Dim PDFApp As AcroApp

          Dim PDFDoc As AcroAVDoc

          Dim PDFPageView As AcroAvPageView

          Dim PDFPath As String

          Dim DisplayPage As Integer

         

          PDFPath = "C:\Users\info_000\Desktop\test.pdf"

         

         

          'Set the page you want to be displayed

          DisplayPage = 1

         

          'Initialize Acrobat by creating App object

          Set PDFApp = CreateObject("AcroExch.App")

         

          'Set AVDoc object

          Set PDFDoc = CreateObject("AcroExch.AVDoc")

         

          'Open the PDF

          If PDFDoc.Open(PDFPath, "") = True Then

              PDFDoc.BringToFront

             

              'Maximize the document

              Call PDFDoc.Maximize(True)

             

              Set PDFPageView = PDFDoc.GetAVPageView()

             

              'Go to the desired page

              'The first page is 0

              Call PDFPageView.GoTo(DisplayPage - 1)

             

          

             

              'Set the page view of the pdf

              Call PDFPageView.ZoomTo(2, 50)

         

          End If

          If PDFDoc.FindText("blabla", 1, 1, 1) = True Then

              Debug.Print "gefunden"

              call pdfdoc.

          Else

              Debug.Print "nicht gefunden"

          End If

          Set PDFApp = Nothing

          Set PDFDoc = Nothing

         

          On Error Resume Next

         

          'Show the adobe application

          PDFApp.Show

         

          'Set the focus to adobe acrobat pro

          AppActivate "Adobe Acrobat Pro"

             

      End Sub