Hi,
I am using some code I found online to find a text string in a PDF.
What I need to do is select the text that is to the right of the text string, lets say 15 characters that appear to the right of the string. Any suggestions?
Thanks,
RugbyKorn
I am using some code I found online to find a text string in a PDF.
Code:
Private Sub Command3_Click()
'IAC objects
Dim gAvDoc As Object
'variables
Dim Resp 'For message box responses
Dim gPDFPath As String
Dim sText As String 'String to search for
Dim sStr As String 'Message string
Dim foundText As Integer 'Holds return value from "FindText" method
'hard coding for a PDF to open, it can be changed when needed.
gPDFPath = "C:\Documents and Settings\user\Desktop\testsearchpdf.pdf"
'Initialize Acrobat by creating App object
Set gApp = CreateObject("AcroExch.App")
gApp.Hide
'Set AVDoc object
Set gAvDoc = CreateObject("AcroExch.AVDoc")
' open the PDF
If gAvDoc.Open(gPDFPath, "") Then
sText = "SD15"
'FindText params: StringToSearchFor, caseSensitive (1 or 0), WholeWords (1 or 0), ResetSearchToBeginOfDocument (1 or 0)
foundText = gAvDoc.FindText(sText, 1, 0, 1) 'Returns -1 if found, 0 otherwise
Else
' if failed, show error message
Resp = MsgBox("Cannot open" & gPDFPath, vbOKOnly)
End If
If foundText = -1 Then
'compose a message
sStr = "Found " & sText
Resp = MsgBox(sStr, vbOKOnly)
Else
' if failed, show error message
Resp = MsgBox("Cannot find" & sText, vbOKOnly)
End If
gApp.Show
gAvDoc.BringToFront
End Sub
Thanks,
RugbyKorn
Comment