I'm trying to run a macro called 'CopyVisibleRanges' in Excel but there is a problem. Anyone see what error is in attached?
There's a connection between VBScript and VBA ?
There's no obvious sign of an interface to VBA in the AppleScript scripting dictionary for Excel. Not sure how you derived that incantation.
( Possibly more fruitful to experiment with launching an Excel VBA macro by automating menu path selections from Keyboard Maestro )
There is no command run VBScript
in Excel's dictionary.
The command is run VB macro
.
So your code should be:
tell application "Microsoft Excel"
activate
run VB macro "CopyVisibleRanges"
end tell
Depending on what exactly it is that the CopyVisibleRanges
macro does, you could possibly do the same thing in AppleScript alone, without having to invoke a VB macro.
I cannot make the macro work, using above Keyboard Maestro macro.
To run the macro, I have to go to Tools > Macro > Macros... in Excel. This brings up attached box and I have to click "PERSONAL.XLSB!Sheet1.CopyVisibleRanges".
Know how to make macro work using Keyboard Maestro macro?
I'm not in front of a Mac with Office to check this, but have you clicked the Options button as shown in your picture? Microsoft software is often good at allowing users to customize things like keyboard shortcuts within their applications, and that's where such an option is likely located.
My automation of Excel - which is quite extensive - has been either AppleScript direct manipulation or, less reliably, keystroke / menu automation.
I've not yet managed to run VBA macros; It does occur to me that injection into a spreadsheet cell might have some value here.
Did you include PERSONAL.XLSB!Sheet1.
as part of the name of your macro to run?
So:
Worked for me from an AppleScript in Script Debugger and from a KM Execute AppleScript action.
That worked thanks