0

This is a continuity question of the below link. https://stackoverflow.com/a/56649098?noredirect=1 I need to do two things 1. Copy all text from PDF and paste it to the excel 2. Copy multiple lines and run a loop to find the text I need

The background of my project - I am opening a webpage with user credentials, after couples of clicks a PDF is opened in the browser. So now I need to get a particular statement from it. The problem is that the PDF is dynamic and the statement I require keeps changing (the line sometimes it is in 6th and sometimes in 9th or 10th and 11th) so the 2 things which I mentioned above will help me I am aware both sounds the same but it is different. Below is the code I used to get a particular statement, but how do I create a loop through all the statement or get multiple statements.

Const statext As String = _
"addEventListener('message',function(e){" & _
" if(e.data.type=='getSelectedTextReply'){" & _
"  var txt=e.data.selectedText;" & _
"  callback(txt && txt.match(/[^\r\n]+/g)[7]);" & _
" }" & _
"});" & _
"plugin.postMessage({type:'initialize'},'*');" & _
"plugin.postMessage({type:'selectAll'},'*');" & _
"plugin.postMessage({type:'getSelectedText'},'*');"

Casestatus = bot.ExecuteAsyncScript(statext)

I am very new to programming and automation so I may be missing a basic thing. Kindly pardon me.

4
  • The only experience I have with .pdf to Excel is opening the hard file from the PC. Open the PDF in Word and then you are able to copy text as required (easier imo). So what I would say is save the PDF to a drive location that you can the use the above method. Commented Jun 29, 2019 at 15:05
  • what happens when you just use callback(txt && txt.match(/[^\r\n]+/g)); and pass that back into a string variable then try generating a string array by splitting the string var on new line? My worry is reading into a string var the text may contain too many characters. Commented Jun 30, 2019 at 6:06
  • Let me try that and get back. Commented Jun 30, 2019 at 8:53
  • @QHarr I have tried with this code - callback(txt && txt.match(/[^\r\n]+/g)) but is throws an error in this line - Casestatus = bot.ExecuteAsyncScript(statext) Error = Run time Error 05 - invalid procedure call or argument. so I changed the datatype from string to Variant, then too it says the same error. Also the total text in the PDF is 1800 characters. Commented Jul 4, 2019 at 10:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.