I am using VBA to loop through about 1,000 PDF's and extract a specific data element. I have the code that can find the specified string, but i need to copy the number that comes after the searched string. see image below of the text that is already highlighted from the search, but now i need to highlight the text that comes after.
I am using the sendkeys method to navigate the PDF documents, i have tried to use Sendkey "+{Right}"
or Sendkey "^+{Right}"
to highlight the data element, but the problem i am having is that once the search is complete, the pdf is stuck in like a scroll lock type of status, where Sendkey "+{Right}"
just sends the document to the next page instead of highlighting the text to the right.
Would anyone know of a method to get the data element highlighted, and copied to my clipboard for pasting into the excel sheet?
Below is a snippet of my approach to getting the data from the pdf file.
ActiveWorkbook.FollowHyperlink MyFolder & "\"& MyFile
waitTime = Now
While DateDiff("s", waitTime, Now)
DoEvents
Wend
''send ctrl+f to open find function in pdf
SendKeys "^f", True
''insert our search string
SendKeys searchstring, True
''press enter to search
SendKeys "{Enter}", True
''escape to exit the search function
SendKeys "{ESC}", True
''attempt to highlight data element to right of search string
SendKeys "^+{Right}", True
''copy highlighted text
SendKeys "^c", True
Application.Wait Now + TimeValue("0:00:05")
''close pdf
SendKeys "^{F4}", True
thiswb.Activate
lrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
Range("A"& lrow).Select
Selection.Value = MyFile
''paste data from clipboard
ClipboardToCell Range("B"& lrow)
thanks!