Just trying to figure out how to manipulate PPT slides with AppleScript. Having a bit of difficulty understanding the dictionary, specifically when it comes to duplicating slides.
This is the closest I’ve gotten:
tell application "Microsoft PowerPoint"
activate
tell active presentation
duplicate slide 1 to slide 3
end tell
end tell
However, when I run that, I get this error:
error “Microsoft PowerPoint got an error: Can’t set slide 3 of active presentation to slide 1 of active presentation.” number -10006 from slide 3 of active presentation
You probably need to duplicate “to after” (or “to before”).
I fussed with duplicate and couldn’t get it to work either. Here is a substitute routine that will copy any slide you specify and paste it at the end of the presentation. Hope it helps.
my duplicateSlide(3)
on duplicateSlide(whichSlide)
-- whichSlide is an integer of the slide to duplicate's position
tell application "Microsoft PowerPoint"
activate
tell active presentation
copy object slide whichSlide
paste object
end tell
end tell
end duplicateSlide
Browser: Firefox 50.0
Operating System: Mac OS X (10.10)
An alternative that is sometimes better is to use the Paste function from the Edit menu with:
tell application "System Events" to tell process "Microsoft PowerPoint" to click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
Duplicating existing slide 1 to existing slide 3 (that is, replacing the second one) :
replace_Slide given sourceSlide:1, destinationSlide:3
tell application "Microsoft PowerPoint" to activate
on replace_Slide given destinationSlide:destinationSlideIndex, sourceSlide:sourceSlideIndex
tell application "Microsoft PowerPoint"
activate
tell active presentation
copy object slide sourceSlideIndex
select slide (destinationSlideIndex - 1)
tell application "System Events" to keystroke "v" using command down
delete slide (destinationSlideIndex + 1)
end tell
end tell
end replace_Slide
NOTE: paste object command of “Microsoft PowerPoint” pastes the duplicate only to the end of the document.