Call Workbook and sheet in Excel via COM and AutoHotKey

beatified
beatified used Ask the Experts™
on
In an AHK Script I would like to call Excel to use a specific workbook and sheet. I'm unaware of what the com objects are for those things.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer
Fellow 2017
Most Valuable Expert 2018
Commented:
Hi Stuart,

> In an AHK Script I would like to call Excel to use a specific workbook and sheet.

Here's an AutoHotkey script that does it:

+F12:: ; Shift+F12 - change to whatever hotkey you want
Workbook:="c:\temp\ExcelFile.xlsx" ; set to file path/name
Worksheet:="worksheet name" ; set to worksheet name
oExcel:=ComObjCreate("Excel.Application")
oExcel.Visible:=True ; set to False if you don't want it to be visible
oExcel.Workbooks.Open(Workbook)
oExcel.Sheets(Worksheet).Select
Return

Open in new window

Regards, Joe
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018
Hi Stuart,
I'm trying to clean up open questions at EE...this is one of them. Do you need more help with it? Regards, Joe

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial