Find text in pdf file

G

Guest

I have been trying to build a search of text in pdf files but the return
value is true even when no text is found. Does anyone see a problem with this
code?
Thanks in advance.

Dim Exch As CAcroApp, AVDoc As CAcroAVDoc
Dim strResult As Long
Set Exch = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
szText = Me.SearchPDF 'unbound text box for User input

AVDoc.Open CurrentProject.path & "\purchase orders\" & Me.PDFfile, "No Title"
DoEvents

strResult = AVDoc.FindText(szText, False, False, True)
MsgBox strResult, vbOKOnly 'shows -1 even when no match is found

If strResult = True Then
MsgBox ("Found Match")
Else: MsgBox ("No Match found")
End If

AVDoc.Close True

Set Exch = Nothing
Set AVDoc = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top