Skip to main content
Robert at ID-Tasker
Brainiac
October 20, 2024
Question

How to Select Multiple Pages in InDesign UI or Script?

  • October 20, 2024
  • 5 replies
  • 1882 views

What is your way of selecting multiple pages in UI - consecutive or not - so this selection info can be read from the script?

Or how do you select pages from script so selection can be read back. 

 

 

<Title renamed by MOD>

 

This topic has been closed for replies.

5 replies

Adobe Expert
October 23, 2024

> But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first. 

 

No need to invoke(). Not with JavaScript, anyway.

Robert at ID-Tasker
Brainiac
October 23, 2024
quote

> But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first. 

 

No need to invoke(). Not with JavaScript, anyway.


By @Peter Kahrel

 

If you just select pages - you won't be able to read selection back. 

 

Invoke is to make the selection stay and be readable back - for example, you could select some pages, then tell user to select more or unselect some.

 

Without invoke - you won't be able to read modified selection. 

 

Adobe Expert
October 23, 2024

I have nothing selected in the document, and in the Tools panel, the selection tool is active.

 

Then I do

 

d = app.documents[0];
app.select(d.pages[2]);
app.select(d.pages[4],SelectionOptions.ADD_TO);

 

And when I then do app.selection, an array with the two selected pages is returned. No invoke() needed.

Adobe Expert
October 23, 2024

With nothing selected in the document, and some pages selected in the Pages panel,, app.selection returns undefined. So pages selected in the Pages panel are not exposed to scripting.

 

Only when you use the Page tool from the Tools panel to select some pages does app.selection return the selected pages.

 

Sure, you can use app.select() to create an array of selected pages. And then app.selection returns that array.

Robert at ID-Tasker
Brainiac
October 23, 2024

@Peter Kahrel

 

And that's the correct answer 🙂

 

But, in case of simulating selection of the pages - you need to execute invoke with the correct ID to select Pages Tool first. 

 

I never said it doesn't require one small extra step 😉 but is way easier than creating some temporary TFs - and is very easy to do by the user in the UI. 

 

FRIdNGE
Inspiring
October 23, 2024

You mean: select pages in the Pages panel?

 

(^/)  The Jedi

Robert at ID-Tasker
Brainiac
October 23, 2024
quote

You mean: select pages in the Pages panel?

 

(^/)  The Jedi


By @FRIdNGE

 

Both - read selection made manually in the UI and simulate this selection.

 

rob day
Adobe Expert
October 23, 2024

Hi @Robert at ID-Tasker , The best you can do is set or get the active page or spread—activePage only returns a single page, not an array of pages:

 

//make page 2 active
app.activeWindow.activePage=app.activeDocument.pages[1];
//get active page
$.writeln(app.activeWindow.activePage.name)

 

Also app.activeWindow.activePage can still be unreliable—depends on the zoom level—the frontmost page doesn't always correspond to the selected page in the Pages panel,

Robert at ID-Tasker
Brainiac
October 23, 2024

@rob day

 

As I've just replied to @Peter Kahrel - let's not skip to the solution so quickly 😉

 

Adobe Expert
October 23, 2024

As far as I know, selected items in InDesign panels aren't exposed to scripting.

Robert at ID-Tasker
Brainiac
October 23, 2024
quote

As far as I know, selected items in InDesign panels aren't exposed to scripting.


By @Peter Kahrel

 

In case of the Pages panel - it is possible to read selection in the script. 

 

But let's make it a brain teaser for today 😉 

 

I can't be the only one who found the solution? 

 

FRIdNGE
Inspiring
October 23, 2024

No! Uwe laubender has already explained how to play 8 years ago!

 

https://community.adobe.com/t5/indesign-discussions/active-page-vs-selected-page/m-p/8776559#M35089

 

(^/)