Search code examples
applescriptiwork

...with Properties {name:"***"} not working


Sorry if this is a noob question, I am just trying to learn this lovely program known as applescript.

tell application "Numbers" ¬ activate end

tell application "Numbers" to ¬ make new document with properties {name:"document 3"} end

I can use this format of script to open most any other application (other than iWork) and it will open up, make a new document, and name it, but for whatever reason it will not work with iWork.

I have even tried to set a variable to use in the {name:variable} or {name:"variable"} with no luck.

Any help would be appreciated, thanks in advance.

PS...Snide comments will be tolerated if they bring me the solution!


Solution

  • I do have Numbers. Try this:

    tell application "Numbers"
        set myDoc to make new document with properties {name:"document 3"}
        name of myDoc
    end tell
    

    The results window should show "document 3". Why do you say it is not working? Possibly because the window that contains the document is labeled "Untitled"? That's because a window does not show the document name until the document is saved. If you choose "Save" from the menu, you will see your document name right there in the save dialog, and the window title will update after the save.