How to save,close and exit Keynote using AppleScript?

1.4k views Asked by At

What's the proper Applescript syntax to save, then close and then exit Keynote after exporting slides? I'm not very experienced in Applescript. Is there something more efficient to use? Shell scripts? Need to also get success/failure of the executed Applescript.

I get the Keynote presentation opened correctly, export the slides, but cannot seem to get Keynote to save the presentation, close it properly and exit.

Tried multiple variations of:

"tell application "System Events"

" tell process "Keynote"

" Save"

" end tell"

" tell process "Keynote"

" Close"

" end tell"

"tell application "Keynote"

" Close "

Also tried:

"tell application "System Events"

" tell process "Keynote"

" click menu item "Close" of menu "File" of menu bar item "File" of menu bar 1"

" click menu item "Quit Keynote" of menu "Keynote" of menu bar item "File" of menu bar 1 "

"end tell"

"end tell"

1

There are 1 answers

0
Kassym Dorsel On

The following will work if there is only one presentation open and it has already been saved (Won't prompt for a save location).

tell application "Keynote"
    save
    quit
end tell