Running macro in Excel PERSONAL.XLSB no longer working?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Running macro in Excel PERSONAL.XLSB no longer working?

03 Jan 2019, 16:28

Hi all,

I have been using AHK for a little while now, and I have been running macros housed in my PERSONAL.XLSB workbook just fine. For some reason, this is no longer working.

The code as per below:

Code: Select all

ExcelActions_MergeAndWrap:

If WinActive("ahk_class XLMAIN") {

Macro:= "PERSONAL.XLSB!MergeAndWrap"
try xlApp := ComObjActive("Excel.Application")

xlApp.Run(Macro)	;fails here, doesn't like Run anymore?

}

Return

The error:

Error 0x80010001 - Call was rejected by callee.

Specifically: Run

xlApp.Run(Macro)


Some info:

• I did receive a new PC box recently and had to copy my xlsb in from a back up location
• It has worked in the past

Any ideas as to what is stopping this now?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Running macro in Excel PERSONAL.XLSB no longer working?

04 Jan 2019, 05:56

Hello submeg
I think the error occurs because the EXCEL is in edit mode, try this

Code: Select all

#If WinActive("ahk_class XLMAIN") 
q::
If (IsEditing()){
    Msgbox 0x40000, % A_ThisFunc, % "EXCEL is EDITING!!"
    Return	
}
Macro:= "PERSONAL.XLSB!MergeAndWrap"
try xlApp := ComObjActive("Excel.Application")
xlApp.Run(Macro)	;fails here, doesn't like Run anymore?
Return

IsEditing() {
 Try {
   ComObjActive("Excel.Application").Interactive := False
   ComObjActive("Excel.Application").Interactive := True
 } Catch {       
    Return True
	 }
 Return False
} 
#If

Donec Perficiam
User avatar
submeg
Posts: 326
Joined: 14 Apr 2017, 20:39
Contact:

Re: Running macro in Excel PERSONAL.XLSB no longer working?

28 Jan 2019, 16:48

Hi jmeneses,

I implemented your code and yes, it returned with "EXCEL is EDITING!"

Looking at the extract, does it try to make sure it is off before running it? I tried it and it continually showed the messagebox each time I tried to run the script. What is supposed to happen in this case?

submeg

Edit: I also found this https://www.autohotkey.com/boards/viewtopic.php?t=27893
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 183 guests