Consulting

Results 1 to 2 of 2

Thread: Return PDF Page Number Using FindText

  1. #1
    VBAX Contributor
    Joined
    Jun 2014
    Posts
    106
    Location

    Post Return PDF Page Number Using FindText

    I found the following example which works great but I can't figure out how to return the page number the string was found on. Does anyone have any idea on how to do it?
    HTML Code:
    sub FindStr ()
    
        Dim TextToFind  As String
        Dim PDFPath     As String
        Dim App         As Object
        Dim AVDoc       As Object   
    
        'Initialize Acrobat by creating the App object.
       
        Set App = CreateObject("AcroExch.App")
    
        PDFPath = "C:\temp\test.pdf 
     
        'Initialize Acrobat by creating the App object.
        Set App = CreateObject("AcroExch.App")
        'Create the AVDoc object.
        Set AVDoc = CreateObject("AcroExch.AVDoc")
     
        'Open successful, bring the PDF document to the front.
         AVDoc.BringToFront
      
         'Search from 1st page:  If true, the search begins on the first page of the document. If false, it begins on the current page (in this example is False).
         If AVDoc.FindText(TextToFind, True, True, False) = False Then
              
               'What I was hoping to find
               debug.print avdoc.pagenumber
      
         End If
    end sub
     

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "A beggar of love, second hand hero...King of Dreams"
    Posts
    2,604
    https://community.softwaregrp.com/dc...with%20QTP.pdf

    check this tutorial.

    since acrobat is not installed in my computer i can't test the methods, etc.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Tags for this Thread

Posting Permissions

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