I've got a PowerPoint file with a single slide and my goal is to copy that one slide into a different PowerPoint file.
Using macOS Sonoma 14.0 with Microsoft Office 365 PowerPoint 16.78 (late 2023)
I've tried several variations of:
tell application "Microsoft PowerPoint"
activate
-- Get the source and destination presentations
set sourcePresentation to open presentation file "source.pptx"
set destinationPresentation to open presentation file "destination.pptx"
-- Get the slide to copy from the source presentation
set sourceSlide to slide 1 of sourcePresentation
-- Copy the slide to the destination presentation
copy object sourceSlide
paste object to destinationPresentation
-- Close the source presentation
close presentation sourcePresentation
end tell
Ultimately I'd like to point the final script at a folder full of .pptx files and have it insert the slide into each of destination deck in the second position. But I'd settle for a basic slide copy across decks right now. :)
This should get you started. Note that there is a switch in 'mode' from presentation to window in order to use the
paste objectcommand.It seems that the paste object will deposit whatever had been copied to after the selection — in this case, after slide 1.
You should be able to find numerous answers here that demonstrate using a repeat loop to cycle through a list of files.
Specific to powerpoint though, the syntax for opening a file is just
openfollowed by the file reference. You can get the file reference by using thechoose filecommand. Try running something likechoose filein a separate script and it will return the appropriate file reference. Then use that result with your open command in this script.