How to run Excel macro?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Micromegas
Posts: 260
Joined: 28 Apr 2015, 23:02
Location: Germany

How to run Excel macro?

08 May 2015, 02:12

There was a 6 years old discussion at AutoHotkey.com, which recommended using either

Code: Select all

oExcel := ComObjActive("Excel.Application")
try oExcel.Run("MyMacro")
or, supposedly better,

Code: Select all

oExcel := Excel_Get()
try oExcel.Run("MyMacro")
The first one doesn't elicit a response from Excel to the hotkey I assigned, and the second one fails with "Error: Call to nonexistent function." Has this changed since then, or is there anything I'm forgetting?
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: How to run Excel macro?

08 May 2015, 02:43

excel_get() is a UDF so you need the function in your script

All try and Remove the TRY on the run Line to see the error it may give
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
User avatar
Micromegas
Posts: 260
Joined: 28 Apr 2015, 23:02
Location: Germany

Re: How to run Excel macro?

08 May 2015, 10:40

Thank you, that showed me my VBA error, and it works now.

For future reference, I also found this related forum discussion: ComObjActive(CLSID).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: just me, Oblomov228, OrangeCat, Perpendie, piddly and 249 guests