Returns an Excel application object.
App := Excel_Get([WinTitle, Excel7#])
Parameters:
WinTitle - Optional. Specify a WinTitle to match. Or omit the WinTitle to use the default "ahk_class XLMAIN" which will get the active window.
Excel7# - Optional. Default is 1. Don't change this unless you know what it does.
[ github ] [ download ] (Right-click > SaveAs)Excel7# - Optional. Default is 1. Don't change this unless you know what it does.
Example Usage:
Code: Select all
F7:: ; Press F7 to display Excel's caption.
xlApp := Excel_Get()
if !IsObject(xlApp) ; If Excel_Get fails it returns an error message instead of an object.
{
MsgBox, 16, Excel_Get Error, % xlApp
return
}
MsgBox, % "Caption: " xlApp.Caption
return
- It can match a WinTitle.
- If Excel is in edit-mode, attempting a COM action will produce an error. Excel_Get detects this error and uses ControlSend to send {Escape} to the workbook window.
- ComObjActive returns the "active" object from the running object table (ROT). "Active" on the ROT does not mean that the window is active. So if more than one Excel application/process is running, ComObjActive does not necessarily return the application object of the active Excel window.
- If Excel was just opened it may not have registered itself on the ROT yet.