The ability to create a Numbers document using a specific template is enabled by the inclusion of the document template property of the document class. (⬇ see below )
The Numbers Suite Document Class
documentn : The Numbers document. synspreadsheet
elements
contains sheets; contained by application.
properties
active sheet (sheet ) : The active sheet in the document.
document template (template, r/o) : The template assigned to the document. This property’s value can be set during document creation.
The value of the document template property (⬆ see above ) is the template currently used (or to be used) by the document in the display of its contents.
NOTE: The document template property is currently read only (except when used with the make command) and cannot be used to change the current template of a Numbers document.
The script below demonstrates the use of the make command to create a new document with a template chosen by the script user:
New Document with Chosen Template
01
tellapplication "Numbers"
02
activate
03
try
04
-- get template names
05
set thetemplateNamesto thenameof everytemplate
06
07
-- prompt user to pick a template
08
setthisTemplateNameto ¬
09
(choose from listtemplateNameswith prompt "Choose template:")
10
ifthisTemplateNameisfalsethen errornumber -128
11
12
-- convert resulting list into string: {"Black"} to "Black"
13
setthisTemplateNametothisTemplateNameasstring
14
15
-- create default document, styled with the chosen template
The following script is designed to create a new Numbersdocument using a specific user template. If the user template is not installed on the computer running the script, the script will prompt the script user to download the specified user template from the company website, and will display the company-hosted website page containing the template if the user desires.
Create Document with Specific User Template
01
tellapplication "Numbers"
02
activate
03
try
04
-- get application template names
05
settheseUserTemplateNamesto ¬
06
thenameof everytemplatewhoseidof it begins with "User/"
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.