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:

AppleScript-run-VB-macro.png
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?
Mac OS XMicrosoft OfficeVBA

Avatar of undefined
Last Comment
Jamie Garroch (MVP)

8/22/2022 - Mon
strung

Try
tell application "Microsoft PowerPoint"
activate
tell active workbook
run VB macro "myMacroName"
end tell
ASKER CERTIFIED SOLUTION
strung

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Jamie Garroch (MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy