Skip to main content
Participating Frequently
July 13, 2010
Answered

Naming new document

  • July 13, 2010
  • 2 replies
  • 984 views

As part of an AppleScript I'm developing, I'm creating a new document which I want to give a specific name. So I tried:

tell application "Adobe Illustrator"

make new document with properties ¬

{color space:RGB, name: myString}

end tell

However, the document always appears with the name "Untitled-1". Is there a way of giving the document a name when you create it? Or can you only do it when saving?

This topic has been closed for replies.
Correct answer wysiwygbill

I needed the same thing and found the answer using the DocumentPreset object.

In JavaScript I set the name of the new document in the DocumentPreset options and applied that when I created the document. getPoints is just a conversion from inches to points, btw.

var docPreset = new DocumentPreset;
docPreset.units = RulerUnits.Inches;
docPreset.width = getPoints(13.0);
docPreset.height = getPoints(18.0);
docPreset.title = 'test document';
docPreset.colorMode = DocumentColorSpace.CMYK;

var doc = app.documents.addDocument(DocumentColorSpace.CMYK,docPreset);

2 replies

wysiwygbillCorrect answer
Inspiring
July 14, 2010

I needed the same thing and found the answer using the DocumentPreset object.

In JavaScript I set the name of the new document in the DocumentPreset options and applied that when I created the document. getPoints is just a conversion from inches to points, btw.

var docPreset = new DocumentPreset;
docPreset.units = RulerUnits.Inches;
docPreset.width = getPoints(13.0);
docPreset.height = getPoints(18.0);
docPreset.title = 'test document';
docPreset.colorMode = DocumentColorSpace.CMYK;

var doc = app.documents.addDocument(DocumentColorSpace.CMYK,docPreset);
Participating Frequently
July 14, 2010

Cool, I'll look into that. I've managed to hack my way around the problem for now, but it's good to know about document presets for the future. Thanks.

Muppet_Mark-QAl63s
Inspiring
July 13, 2010

Name is read only so I think you are stuck until your first save but you could add one right after creating it?

Participating Frequently
July 13, 2010

Well, there's always GUI scripting since it's possible to name a document at the point of creation in the GUI. Which is why I would have expected to be able to do it in the scripting interface