I have a situation where I have several Powerpoint files (each containing multiple slides) and I’d like to develop an Applescript that will take all the slides from specific files and merge them into one master file. I will need to keep the formatting intact (perhaps with a section/page breaks?).
This is what I have so far (commented area shows where I am missing proper code):
set theItems to {}
set x to 0
repeat until (count of theItems) > 1
set theItems to choose file with prompt "Select two or more Powerpoint Files." with multiple selections allowed without invisibles
end repeat
tell application "Microsoft PowerPoint"
activate
make new presentation
repeat with aFile in theItems
tell application "Finder"
set fileRef to ((a reference to file aFile) as string) --not sure about this line
end tell
insert file at text object of selection file name fileRef --getting error on this line - improper syntax
if x < ((count of theItems) - 1) then
insert break at text object of selection
end if
set x to x + 1
end repeat
end tell
Okay, I’ve decided to run a simple script on two presentations. I wanted to loop through slides in presentation 2, and copy them into presentation 1:
tell application "Microsoft PowerPoint"
set preso1 to presentation 1
set preso2 to presentation 2
repeat with a from 1 to count slides of preso2
copy object slide a of preso2
paste object preso1
end repeat
end tell
That works fine. But now, I need to have files preselected and here is what I’ve written but with no success. I would appreciate some help. Thanks.
set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
tell application "System Events"
set these_files to path of every file of folder this_folder whose name does not start with "." and file type is "ppt"
end tell
tell application "Microsoft PowerPoint"
activate
set this_presentation to make new presentation
repeat with i from 1 to the count of these_files
set this_file to (item i of these_files)
copy object slide i of this_file
paste object this_presentation
end repeat
end tell
What about this?
Style of the slide will get lost.
property PPT_EXTENSIONS : {"ppt", "pptx"}
set this_folder to (choose folder with prompt "Pick the folder containing the files to process:") as string
set allFolderFiles to list folder this_folder without invisibles
tell application "Microsoft PowerPoint"
activate
-- make new pres to copy to
set this_presentation to make new presentation
-- repeat with all files
repeat with i in allFolderFiles
-- construct full path
set fileHSF to (this_folder as text) & i
-- if ppt or pptx
if name extension of (info for alias fileHSF) is in PPT_EXTENSIONS then
-- open file
open alias fileHSF
set myDoc to presentation fileHSF
-- copy every slide
repeat with i from 1 to (count every slide of myDoc)
copy object slide i of myDoc
paste object this_presentation
end repeat
close myDoc saving no
end if
end repeat
end tell
Hope it helps,
ief2
This part:
copy object slide i of myDoc
paste object this_presentation
copies the images and text fine but I need to retain the slide’s design, such as the background. Is there syntax to do that? Much appreciated.