1

I have Keynote presentations that contain slides with item builds. I would like to be able to remove item builds from every slide of a given presentation automatically (i.e., without clicking on each slide individually, opening its build order, and removing the build order entries).

Things I've tried so far:

  • I tried accessing a Keynote document with AppleScript, but according to the Script Editor dictionary entries for Keynote, a Keynote document appears not to expose per-slide builds (animations). I expected to find that slide objects would expose the items on the slide and their build properties, but currently, this appears not to be the case.
  • I tried writing an AppleScript to open up the build order for every slide and remove all entries, but I am having difficulty accessing the build order window entries automatically.

I haven't yet tried using Automator, but maybe there's a way to do it with Automator?

1
  • Does your script work on one slide yet? Posting your code as an answer or on the question often helps someone get you past an error if you can show your work so far Commented Sep 5 at 17:51

1 Answer 1

1

Here's an AppleScript that programmatically uses the GUI to clear all transitions and animations. To just remove all item builds (and leave any slide transitions intact), remove the call to ensureNoTransition and its associated return code logic.

The delay timings I used could be tuned (it's perhaps a bit slow), but it seems to get the job done.

I recommend backing up your presentation beforehand and closing other presentations to minimize the chances of data loss.

 -- Clears slide transitions and animations in Keynote. property DEBUG_MODE : true on dbg(msg) if DEBUG_MODE then log msg end dbg on gotoSlide(i) tell application "System Events" to tell process "Keynote" keystroke "g" using {command down, control down} -- Slide → Go To → Slide… delay 0.05 keystroke (i as text) key code 36 -- Return end tell end gotoSlide on showAnimate() tell application "System Events" to tell process "Keynote" if exists (button "Animate" of toolbar 1 of window 1) then click button "Animate" of toolbar 1 of window 1 delay 0.05 end if end tell end showAnimate -- Return one of {"cleared","alreadyNone","failed"} on ensureNoTransition() tell application "System Events" to tell process "Keynote" set w to window 1 -- If we see "Add an Effect" or "No Transition Effect", it is already None if (exists button "Add an Effect" of w) then return "alreadyNone" try set lbls to every static text of w repeat with L in lbls try if name of L is "No Transition Effect" then return "alreadyNone" end try end repeat end try -- If there is a Change button, open the picker and choose None by keyboard if exists button "Change" of w then click button "Change" of w delay 0.1 keystroke "n" -- jump to "None" delay 0.05 key code 36 -- Return delay 0.1 return "cleared" end if end tell return "failed" end ensureNoTransition -- Clear animations on a single slide. on ensureNoAnimations() tell application "Keynote" to activate tell application "System Events" to tell process "Keynote" if exists (button "Animate" of toolbar 1 of window 1) then click button "Animate" of toolbar 1 of window 1 end tell tell application "System Events" to tell process "Keynote" key code 53 -- Esc, exit text-edit mode if any delay 0.05 keystroke "a" using {command down} -- select all objects on slide end tell tell application "System Events" to tell process "Keynote" -- click the "Build In" tab if exists button "Build In" of window 1 then click button "Build In" of window 1 delay 0.05 -- if "Add an Effect" is present, there are no Build In effects to clear if exists button "Add an Effect" of window 1 then return -- otherwise click "Change" then choose "None" via keyboard if exists button "Change" of window 1 then click button "Change" of window 1 delay 0.1 -- Choose "None" via keyboard keystroke "n" delay 0.05 key code 36 -- Return end if end tell tell application "System Events" to tell process "Keynote" if exists button "Action" of window 1 then click button "Action" of window 1 delay 0.05 if exists button "Add an Effect" of window 1 then return if exists button "Change" of window 1 then click button "Change" of window 1 delay 0.1 -- Choose "None" via keyboard keystroke "n" delay 0.05 key code 36 end if end tell tell application "System Events" to tell process "Keynote" if exists button "Build Out" of window 1 then click button "Build Out" of window 1 delay 0.05 if exists button "Add an Effect" of window 1 then return if exists button "Change" of window 1 then click button "Change" of window 1 delay 0.01 -- Choose "None" via keyboard keystroke "n" delay 0.05 key code 36 end if end tell end ensureNoAnimations -- Main tell application "Keynote" if not (exists front document) then display dialog "No frontmost Keynote document." buttons {"OK"} default button 1 with icon caution return end if activate set slideCount to count of slides of front document end tell tell application "System Events" to tell process "Keynote" to set frontmost to true -- Focus the "Animate" panel. my showAnimate() set cleared to 0 set alreadyNone to 0 set failed to 0 -- Clear transitions and animations from every slide. repeat with i from 1 to slideCount my dbg("Slide " & i & ": jump via ^⌘G") my gotoSlide(i) delay 0.05 -- Clear slide transition. set res to my ensureNoTransition() if res is "cleared" then set cleared to cleared + 1 my dbg("Slide " & i & ": set to None") else if res is "alreadyNone" then set alreadyNone to alreadyNone + 1 my dbg("Slide " & i & ": already None") else set failed to failed + 1 my dbg("Slide " & i & ": could not clear") end if -- Then clear builds/animations on this slide my ensureNoAnimations() end repeat display dialog ("Slides processed: " & slideCount & return & ¬ "Newly cleared: " & cleared & return & ¬ "Already none: " & alreadyNone & return & ¬ "Failed: " & failed) buttons {"OK"} default button 1 with icon note 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.