Applescript Action in KM Times Out Invoking MS Excel, But Works From Script Debugger

Need help understanding why executing Applescript action below in KM fails to invoke MS Excel due to time out, but executes successfully from Script Debugger. Similar other posts that I have reviewed have not provided a solution.

When the KM macro is called from a VBA of MS Excel 2011 for Mac running Keyboard Maestro 9.2 on macOS 10.14.6 using the "do script with parameter" command, the initial say command is heard with the expected parameter value, but the second say command only gets executed after the AppleEvent timeout. None of the remaining
Applescript statements are evidenced to be executed. However, the entire Applescript runs successfully when run from Script Debugger (that is with the KM Trigger variable set manually).

The following lines are found in the Engine Log"
Execute macro “AUC Region 3 Performance Ratings - New/Edit Employee Button ” from trigger Do Script
Execute an AppleScript failed with script error: text-script:365:376: execution error: Microsoft Excel got an error: AppleEvent timed out. (-1712)
Execute an AppleScript failed with script error: text-script:365:376: execution error: Microsoft Excel got an error: AppleEvent timed out. (-1712). Macro “AUC Region 3 Performance Ratings - New/Edit Employee Button ” cancelled (while executing Execute AppleScript For Preparing MS Excel Data For HTML).

After observing a "spinning beach ball" for ~ two minutes, the say "We made it this far!" command is heard, the following Run-time message appears on the screen where MS Excel is at the front.:

Selecting the Debug button shows the last executed Excel VBA command which is what successfully initiated the KM macro.

Shortly thereafter, the Macro Cancelled Applescript failed and time-out notification is observed.

Ideas to troubleshoot would be appreciated.

Can anyone help with this issue?

I’ve noticed AppleScript needs a longer timeout for longer macros, I mean, macros that take longer to process. Can’t remember what I did to fix that, will check.

Maybe Peter can help
@peternlewis

AppleScript can adjust the timeout with the with timeout command:

with timeout of 86400 seconds
 
end with
1 Like

Peter,

The timeout did not resolve the issue. This issue seems to be related to the inability of the KM macro to "call back" to the MS Excel workbook (with the AppleScript tell application MS Excel block) that invoked the KM macro from a VBA of that same MS Excel workbook.

In other words, is there any reason that the following workflow is prohibited:
MS Excel workbook with VBA macro calls KM macro that "calls back" to the MS Excel workbook

Is there a workaround?

Thanks

Solved by ccstone using:

One more thing to try with VB script.

Try something like this:

ignoring application responses
   tell application "Keyboard Maestro Engine"
      do script "AFB1EE80-3A76-4E58-A0E8-4C742CBC5C5F"
   end tell
end ignoring

But – this will have to be at the END of your VB macro.

-Chris

2 Likes