Question

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)

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top