Hi all,
I’m incredibly new to all things programming/scripting. 5 days ago I didn’t even know what AppleScript was.
Long story short I’m looking for a way to use the content of one Keynote Presentation to make another Keynote Presentation. The reason for this is because, despite my best efforts to distribute correct templates and style guides, I still get handed incorrect presentations right before an event is due to start.
If there is anyone who would be prepared to help point me in the right direction with this I would be incredibly grateful. I’ve thoroughly enjoyed reading as much as I can and finding as many guides/tutorials as possible however I’ve hit a point where it seems that no amount of googling is helping.
Where I’m at currently:
I’m able to extract the text from a presentation using the following script which was adapted from a post [user=2]KniazidisR[/user] made.
set theText to ""
tell application "Keynote"
set theSlides to slides of document 1
repeat with theSlide in theSlides
tell (contents of theSlide)
set theText to theText & " Slide " & slide number & return & "=========" & return
set theText to theText & object text of iWork item 1 of item 1 of theSlide & return & return
end tell
end repeat
end tell
which will output (for the sakes of this post) the following:
set theText to " Slide 1
=========
Senior School Assembly
23 April 2021
Slide 2
=========
Australians all let us rejoice
For we are one and free
We’ve golden soil and wealth for toil,
Our home is girt by sea:
Our land abounds in nature’s gifts
Of beauty rich and rare,
In history's page let every stage
Advance Australia fair,
In joyful strains then let us sing
Advance Australia fair."
I’ve also had success running the following to create a new presentation, load the correct theme, and create a slide using the correct template.
tell application "Keynote"
activate
set thisDocument to ¬
make new document with properties ¬
{document theme:theme "KeynoteScotchMasterThistle1920_1200"}
tell thisDocument
set base slide of the first slide to master slide "1_Title Slide"
end tell
end tell
Now, what I would really like, is to be able to use the text from the export from the first presentation to create a new slide where required, and then use the text that was extracted to make new text item where required. I want to avoid using default title item and default body item because I’ve had problems before with text going missing if someone resizes the object.
Anyway, if you’ve made it this far, I really appreciate it and I hope someone is able to give me some pointers to get this working.
thanks