Skip to main content
Participant
February 3, 2010
Answered

How do you select a layer by name using Javascript?

  • February 3, 2010
  • 3 replies
  • 9877 views

How do you select a layer by name using Javascript?

You can do this in Applescript using this code:

set active layer of active window to layer "Layout" of myDocument

I can't figure out the correct syntax in Javascript.

Anyone know how to do this?

Any information would be greatly appreciated,

adobeJavaScripter

This topic has been closed for replies.
Correct answer Laubender

In JavaScript you can use the following code:

app.activeDocument.activeLayer=app.activeDocument.layers.itemByName("Layout");


For "app.activeDocument" use "myDocument", if you prefer.

Uwe

3 replies

ramkumar_vp
Inspiring
February 3, 2010

Hi,


Use the below line to select the layer by name.


app.activeDocument.activeLayer = app.activeDocument.layers.itemByName("[Layer Nnme]");


Regards,

Ramkumar .P

Harbs.
Legend
February 3, 2010

item() works the same as itemByName()

Harbs

Robert at ID-Tasker
Legend
February 3, 2010

.

LaubenderCommunity ExpertCorrect answer
Community Expert
February 3, 2010

In JavaScript you can use the following code:

app.activeDocument.activeLayer=app.activeDocument.layers.itemByName("Layout");


For "app.activeDocument" use "myDocument", if you prefer.

Uwe

Participant
February 3, 2010

that worked! Thanks for the help!

- adobeJavaScripter