Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

No Such Element?

New Here ,
Oct 24, 2013 Oct 24, 2013

hi guys,

Im currently trying to write a script for an assignment at Uni and I keep getting

"no such element"

var doc1=app.document[0];

I'm losing my mind!! Im new to scripting and to photoshop and I cant figure it out

please reply!!

TOPICS
Actions and scripting
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Oct 24, 2013 Oct 24, 2013

For that line to work in Photoshop there has to be an open document. And from the error message I would bet there isn't.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 24, 2013 Oct 24, 2013

You have missed the "s" in documents.

var doc1=app.documents[0];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 24, 2013 Oct 24, 2013

I assumed the missing s was a typo in the post not the script itself. Otherwise the error message would have been 'undefined is not an object'. To get the 'no such element' message you need to try to access a document in the collection that doesn't exists. And if the first element doesn't exists that means there are no documents open.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 25, 2013 Oct 25, 2013

app.preferences.rulerUnits = Units.PIXELS;

var doc1=app.documents[0];

var doc2=app.documents[1];

var doc3=app.documents[2];

var doc4=app.documents[3];

var newDoc = app.documents.add(2480, 3508, 300.0,

hi there- I just copied this from my script- the "s"missing was just a typo- sorry im just really stuck and running out of time to get this done!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 25, 2013 Oct 25, 2013
LATEST

Seems you are still having problems posting code, your last line is incomplete.

Try

alert(app.documents.length);

if( app.documents.length > 3 ){

    app.preferences.rulerUnits = Units.PIXELS;

    var doc1=app.documents[0];

   var doc2=app.documents[1];

   var doc3=app.documents[2];

   var doc4=app.documents[3];

}else{

    alert("you don't have enough documents open!");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines