Shortcuts Not Working In MS Excel 2019 VBA Editor (v9.2)

The following shown KM actions executing VBA Editor shortcuts were working without issue in MS Excel 2011 under Mojave, but now when run in the same macro in MS Excel 2019 running Keyboard Maestro 9.2 under macOS 11.6 (Big Sur), the "a" and the "q" appear in the text of the VBA macro rather than "Selecting All", "Closing the Window" or "Quiting the VBA Editor".

Has anyone else seen this issue or have an idea of how to close the VBA Editor window from the KM macro without using UI actions?

Hey Anthony,

This is Micro$loth's doing – not Keyboard Maestro.

You can access menus with Keyboard Maestro.

You can't simulate command-key keyboard shortcuts – I tried with System Events UI-Scripting and got the same results as Keyboard Maestro.

As far as I can see your only option for closing the macro editor window is with UI-Scripting.

Cmd-A can be done with a menu command.

Quit and Return to Excel can be done with a menu command.

-Chris

1 Like

Hey Chris!

You got me thinking laterally about a different (but vaguely related) problem I have:

If I could script the VBA editor for Excel (or Powerpoint) I could parachute in macros stored as text - using Keyboard Maestro. (With md2pptx / python-pptx I'm on the brink of being able to set up buttons in a PowerPoint presentation to call macros so this could actually be useful.)

I have to say I've found 365 applications to be largely inscrutable when it comes to UI scripting. But I have made some progress.

Hey Martin,

Microsoft in their infinite wisdom decided to cripple the Run VBA Macro command in Office App's AppleScript Suites.

It used to be able to run arbitrary code, but now it can only run macros that actually exist.

However – it looks like you can pass arbitrary arguments to a macro.

Unfortunately I don't use VBA enough to know if this will allow the creation of runnable code fragments or not.

You might experiment a bit with that.

-Chris

1 Like

Right. My idea is to use UI scripting.