Opening Keynote and Keynote-compatible documents is accomplished with the open command from the Standard Suite.
open v : Open a document.
open file reference or a list of file references : The file(s) to be opened.
⇒ document or a list of documents : The opened document(s).
Simply add a file reference, in HFS alias or UNIX POSIX path format, as the direct parameter for the command:
open alias "Macintosh HD:Users:Johnny:Desktop:Q1-Report.key"
In the script example below, the file reference used as the direct parameter of the open command, is generated by the choose file dialog, which returns a file reference in HFS alias format.
NOTE: the character ¬ (placed at the ends of lines 4-10) is used to indicate that lines 4-11 are part of a single script statement, which has been segmented and placed on separate lines, for the purpose of fitting within the width constrictions of this column.
TIP: The script above uses the path to command to generate a disk reference to a standard user folder. Enumerations for other standard path to command locations include: documents folder/downloads folder/home folder/movies folder/music folder/pictures folder/public folder/temporary items/shared documents. For more information, view the path to command in the Standard Additions scripting dictionary.
IMPORTANT TIP: Learn how to save and run your favorite scripts using the system-wide Script Menu.
If a script attempts to open a pre-Keynote 2009 document, the following error will be triggered: