PDA

View Full Version : Return PDF Page Number Using FindText



heedaf
08-24-2020, 03:48 PM
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?


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

mancubus
11-05-2020, 11:46 PM
https://community.softwaregrp.com/dcvta86296/attachments/dcvta86296/sws-Fun_TEST_SF/9622/1/Acrobat%20Exchange%20COM%20API%20with%20QTP.pdf

check this tutorial.

since acrobat is not installed in my computer i can't test the methods, etc.