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

select document -1

Engaged ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

I have several opened documents, manually selected is the last one

How I can select the  previous opened document with script?

(I want to loop all)

How I can get the selected document index?

TOPICS
Scripting

Views

263

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Nov 13, 2020 Nov 13, 2020

I don't know what exactly you want.

 

But give this snippet a try:

(Requirement: Three or more documents are already open in Illustrator)

var docs = app.documents;
alert(docs[0].name + " is active");
// way no.1
app.activeDocument = docs[1]; // was previous active - is active now
$.sleep (1000);
// way no.2
app.documents[2].activate(); // was second last active document - is active now

 

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

I don't know what exactly you want.

 

But give this snippet a try:

(Requirement: Three or more documents are already open in Illustrator)

var docs = app.documents;
alert(docs[0].name + " is active");
// way no.1
app.activeDocument = docs[1]; // was previous active - is active now
$.sleep (1000);
// way no.2
app.documents[2].activate(); // was second last active document - is active now

 

Votes

Translate

Translate

Report

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
Engaged ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

LATEST

Thank you for your code, I will try it and post back

Panagiotis

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

document indexing is dynamic. The first element in the collection is always the currently open document. If you open or activate another document, that would become the first document. The second document will be the document that was active prior to activating the current one.

Votes

Translate

Translate

Report

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
Guide ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

The index of documents[i] is the reverse order in which the document was active.  I.e. 0 is active, 1 was active before 0, 2 was active before 1, etc. 

Votes

Translate

Translate

Report

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