1

I'm trying to write an AppleScript that will use the Save as Pictures... function of PowerPoint, but I'm wrestling with AppleScript. This is what I have:

set p to "file.pptx"

tell application "Microsoft PowerPoint"
    launch
    open p
    delay 2
    click menu item "Save as Pictures..." of menu bar item "File" of menu bar 1
end tell

and it isn't doing what I want. The specific error I get is:

script error: Expected end of line, etc. but found class name. (-2741)

And I don't know what to do. I've tried all sorts of things but I can't seem to get the right menu item to click. I'm using OSX 10.9 and PowerPoint 2011 (Version 14.3.2)

UPDATE:

This is now the script I have:

set p to "file.pptx"

tell application "Microsoft PowerPoint"
    launch
    open p
end tell

delay 2

tell application "System Events"
    tell process "PowerPoint"
        click menu item "Save as Pictures..." of menu 1 of menu bar item "File" of menu bar 1
    end tell
end tell

And I'm getting an execution error: Microsoft PowerPoint got an error: Parameter error. (-50)

1
  • Good idea but this turned out to be incorrect. Thanks for the help though! Commented Feb 4, 2014 at 16:03

1 Answer 1

2

Gui automation is generally done through the "System Events" app.

Also you need to provide a full path to a file before trying to open it.

This is how you would begin your attack on PowerPoint correctly.

set p to POSIX file "/Users/drew/Desktop/file.pptx"

tell application "Microsoft PowerPoint"
    launch
    open p
end tell

delay 2

tell application "System Events"
    tell process "PowerPoint"
        click menu item "Save as Pictures..." of menu 1 of menu bar item "File" of menu bar 1
    end tell
end tell
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the help, but this is giving me a different error: execution error: Microsoft PowerPoint got an error: Parameter error. (-50), I added the whole script I have now to the question. I tried a few variations (process/application, "PowerPoint"/"Microsoft PowerPoint", etc.) but always seem to get the same error. I don't even know which part of the script is wrong.
Perhaps you need to enable access for assistive devices, looks like it's changed in mavericks. Look at this tekrevue.com/… and add power point.
@Drew Just noticed you were not using a full path to your pptx file, which is possibly the Parameter error. Have edited my answer to show this as well.
Turned out you were both right. Thanks for all the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.