Created
August 4, 2015 18:34
-
-
Save TLMcode/cf8cf82f71b9333ed3a9 to your computer and use it in GitHub Desktop.
ComExcelConnect() creates a COM connection to a open workbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xlObj := ComExcelConnect( "ahk_class XLMAIN" ).Application | |
msgbox % xlObj.Range("A1").value | |
ExitApp | |
ComExcelConnect( WinTitle ) | |
{ | |
objID := "-16", objID &= 0xFFFFFFFF | |
refID := -VarSetCapacity( iid, 16 ) | |
iid_type := NumPut( 0x46000000000000C0 | |
, NumPut( 0x20400, iid, "Int64" ) | |
, "Int64") | |
ControlGet, hwnd, hwnd, , EXCEL71, % WinTitle | |
DllCall( "oleacc\AccessibleObjectFromWindow", ptr, hwnd, uInt, objID, ptr, refID+iid_type, "ptr*", pObj ) | |
return ComObjEnwrap( 9, pObj ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment