Link to home
Start Free TrialLog in
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Run Office:2011 VBA macro from AppleScript (on OS X Yosemite)

I have seen several methods for running macros from AppleScript on the web but none seem to work. This is the one that looks closest to being relevant for Office:mac 2011:

tell application "Microsoft PowerPoint"
activate
run VB macro "myMacroName"
end tell

Open in new window


But no matter what I put after run VB macro, the script editor keeps throwing this error:

Syntax Error
Expected end of line, etc. but found identifier.


So I opened the relevant dictionary in the script editor to check that the method exists using File / Open Dictionary, selecting the relevant Microsoft Office:mac application and searching for run VB macro I found this:

User generated image
This looks like the macro name and optional parameters are supposed to be on separate lines but that throws the same error.

If it's possible to run a macro and this issue is resolved, where can the macro reside? Only in an open document or can it be called within an installed VBA application add-in too?
Avatar of strung
strung
Flag of Canada image

Try
tell application "Microsoft PowerPoint"
activate
tell active workbook
run VB macro "myMacroName"
end tell
ASKER CERTIFIED SOLUTION
Avatar of strung
strung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jamie Garroch (MVP)

ASKER

The solution required two changes to the original code, one from user strung and one from myself after more reading/prototyping/testing