Paste an OCR to Excel

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Rick0825
Junior Coder
Posts: 28
Joined: Sun Mar 05, 2023 5:30 pm

Paste an OCR to Excel

Post by Rick0825 » Fri Mar 10, 2023 1:59 am

I used the OCR Wizard to grab some text. Text capture would not recognize the text. It looks like the code is

Code: Select all

OCRArea>390,417,480,446,strText
I then open an Excel file and need to paste to a cell. I was close to a solution by using

Code: Select all

MessageModal>strText
I could do a copy and paste from there but I would think their would be a better solution.
Thanks in advance for your help!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1384
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Paste an OCR to Excel

Post by Dorian (MJT support) » Fri Mar 10, 2023 9:25 am

To write to Excel you'd use the native Excel functions.

Let's start by creating and quitting a new test Excel file with XLCreate and XLQuit.

Run this first :

Code: Select all

//Create and Quit our Excel file
XLCreate>%script_dir%\MJT-test.xlsx,1,xlbook
XLQuit>xlbook
Now we can use XLOpen and XLSetCell to open the file and post the data. This posts to cell A5 in Sheet1 :

Code: Select all

OCRArea>390,417,480,446,strText
XLopen>%script_dir%\MJT-test.xlsx,1,xlbook
XLSetCell>xlbook,Sheet1,1,5,strText,res
It might also be worth your time to visit the Excel section in the manual just to familiarize yourself with the Excel functions.
Yes, we have a Custom Scripting Service. Message me or go here

Rick0825
Junior Coder
Posts: 28
Joined: Sun Mar 05, 2023 5:30 pm

Re: Paste an OCR to Excel

Post by Rick0825 » Sun Mar 12, 2023 9:37 pm

Works great. Such a learning curve, but im getting their. :D
Thanks again.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts