The ability to create a Keynote document using a specific theme is enabled by the inclusion of the document theme property of the document class. (⬇ see below )
The Keynote Suite Document Class (excerpt)
documentn : The Keynote document. synpresentation
elements
contains slides, master slides; contained by application.
properties
document theme (theme, r/o) : The theme assigned to the document.
The value of the document theme property (⬆ see above ) is the theme currently used (or to be used) by the document in the display of its contents.
NOTE: The document theme property is now read and write and can be used to change the current theme of a Keynote document.
The script below demonstrates the use of the make command to create a new document with a theme chosen by the script user:
New Document with Chosen Theme
01
tellapplication "Keynote"
02
activate
03
try
04
-- get theme names
05
set thethemeNamesto thenameof everytheme
06
07
-- prompt user to pick a theme
08
setthisThemeNameto ¬
09
(choose from listthemeNameswith prompt "Choose theme:")
10
ifthisThemeNameisfalsethen errornumber -128
11
12
-- convert resulting list into string: {"Black"} to "Black"
13
setthisThemeNametothisThemeNameasstring
14
15
-- create default document, styled with the chosen theme
16
makenewdocumentwith properties ¬
17
{document theme:themethisThemeName}
18
19
on errorerrorMessagenumbererrorNumber
20
iferrorNumberis not -128 then
21
display alert "THEME ISSUE" messageerrorMessage
22
end if
23
end try
24
end tell
The following script, a variation of the previous script, creates a new Keynotedocument using the application theme chosen by the script user:
New Document with Chosen Application Theme
01
tellapplication "Keynote"
02
activate
03
try
04
-- get application theme names
05
settheseApplicationThemeNamesto ¬
06
thenameof everythemewhoseidof it begins with "Application/"
07
08
-- prompt user to pick a theme
09
setthisThemeNameto ¬
10
(choose from listtheseApplicationThemeNameswith prompt "Choose a theme:")
11
ifthisThemeNameisfalsethen errornumber -128
12
13
-- convert resulting list into a string: {"Black"} to "Black"
14
setthisThemeNametothisThemeNameasstring
15
16
-- create a default document, styled with the chosen theme
17
makenewdocumentwith properties ¬
18
{document theme:themethisThemeName}
19
20
on errorerrorMessagenumbererrorNumber
21
iferrorNumberis not -128 then
22
display alert "THEME ISSUE" messageerrorMessage
23
end if
24
end try
25
end tell
The following script is designed to create a new Keynotedocument using a specific user theme. If the user theme is not installed on the computer running the script, the script will prompt the script user to download the specified user theme from the company website, and will display the company-hosted website page containing the theme if the user desires.
Create Document with Specific User Theme
01
tellapplication "Keynote"
02
activate
03
try
04
-- get application theme names
05
settheseUserThemeNamesto ¬
06
thenameof everythemewhoseidof it begins with "User/"
07
08
-- check for installation of user theme
09
setthisUserThemeNameto "Official Corporate Theme"
10
ifthisUserThemeNameis not intheseUserThemeNamesthen
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. MACOSXAUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. MACOSXAUTOMATION.COM provides this only as a convenience to our users. MACOSXAUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and MACOSXAUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from MACOSXAUTOMATION.COM and that MACOSXAUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.