The closing of documents is a fundamental action performed by scripts, and is accomplished using the close command from the Standard Suite.
close v : Close a document.
close specifier : the document(s) or window(s) to close.
[ saving yes/no/ask ] : Should changes be saved before closing?
[ saving in file ] : The file in which to save the document, if so.
The close command has two optional parameters that determine: 1) whether changes made to the document should be saved before it is closed; and 2) in which file the document should be saved.
The example scripts provided below, demonstrate typical uses of the close command:
Close All Documents without Saving | ||
01 | tell application "Keynote" | |
02 | activate | |
03 | close every document without saving | |
04 | end tell |
The following script examines all open documents, closing those which have not yet been saved to file:
IMPORTANT TIP: Learn how to save and run your favorite scripts using the system-wide Script Menu.