Monday

Create a new Indesign document using Javascript

First of all, Javascript is case sensitive, so if you're following along and reusing my code, make sure to be consistent with how you use uppercase and lowercase letters, for example, 'Indesign' and 'InDesign' are two different words in code.

So lets make a start and write some code.

Fire up the ExtendScript Toolkit (ESTK), type in #target indesign


image of ESTK with '#target indesign' typed into code window
















and hit F5 (Cmd+R on a Mac) to run it.

Indesign should start up if it isn't already running and give you this prompt, if so, tick the 'Don't show again' box and click Yes.


Prompt asking 'Do you want to launch Adobe Indesign CS4'












Now, go back to the ESTK and on the next line, type
#target indesign
alert("Hello world");

Hit F5 (Cmd+R on a Mac) and you should see


Alert dialog box showing 'Hello world' in Indesign


Congrats, you've just written your first script. But let's not stop there, our goal here is to actually create a new document, so add this line

#target indesign
alert("Hello world");
app.documents.add();

Hit F5 (Cmd+R) and BAM you have your new document. Party Time!

That's it for now, next time I'll show you how to save and name your document.

johnt

No comments:

Post a Comment