Having trouble searching active Excel sheet Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PiecefulPoem
Posts: 6
Joined: 30 Oct 2021, 10:50

Having trouble searching active Excel sheet

Post by PiecefulPoem » 31 Oct 2021, 16:20

I'm attempting to use OCR to search an excel file and return an adjacent cell contents with no luck. For my purposes I'm not worried about opening any specific sheet, I'd like to just reference whatever I currently have open in Excel.

This is my latest iteration of many attempts:

Code: Select all

#include <Vis2>  ; Equivalent to #include .\lib\Vis2.ahk

#c:: 
OCR()              ; OCR to clipboard

MsgBox, %clipboard%

LookFor = %clipboard%
xl := ComObjActive("Excel.Application")
FoundM := x1.Range("A:A").Find(LookFor).Offset(0,1).Value
	MsgBox, % FoundM
return

Esc:: ExitApp

Esc:: ExitApp

I have Excel open and test contents in Columns A & B. The first MsgBox correctly displays the OCR'd text but the script isn't finding the test text within Excel even though the spelling is identical.

What am I doing wrong here?

User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: Having trouble searching active Excel sheet  Topic is solved

Post by flyingDman » 31 Oct 2021, 16:39

xl not x1!
14.3 & 1.3.7


Post Reply

Return to “Ask for Help (v1)”