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

How to Select Multiple Pages in InDesign UI or Script?

Community Expert ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

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>

 

TOPICS
How to , Scripting

Views

660

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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? 

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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

 

(^/)

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

@FRIdNGE

 

No, my solution is WAY easier - no need to add any TFs or "hope for the best" - WAY less coding required. 

 

Simple 

 

app.selection() 

 

returns selected pages - the same way as if it was bunch of objects selected on the spread. 

 

And you can select pages 1,15,25,55 - or whatever pages you / user wants to select - and you'll get collection of Pages. 

 

And it also works the other way around - you can use:

 

app.select()

 

to select bunch of pages. 

 

 

So, one of the potential uses - let user select bunch of pages - manually - then read this selection, build string for PDF export. 

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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,

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

@rob day

 

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

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

You mean: select pages in the Pages panel?

 

(^/)  The Jedi

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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.

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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.

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

@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. 

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

> 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.

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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. 

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

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.

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

@Peter Kahrel 

 

Sorry, just got back home and tested.

 

invoke() is needed - but even much "earlier" - or user needs to switch to "Page tool" mode himself.

 

There are two problems - if user won't be in "Pages tool" mode:

 

1) if you select pages through script then let user select / deselect pages - but user will be in the "Selection tool" mode - you won't get info about changes,

2) if you switch between apps and come back to InDesign - simple ALT+TAB - and user will be in the "Selection tool" mode - you'll loose selection - pages will be selected in the Pages panel - but you'll get empty app.selection.

 

User HAVE to be in "Page tool" mode BEFORE he starts changing selected pages.

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

Ugh. What a snake-pit scenario.

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

quote

Ugh. What a snake-pit scenario.


By @Peter Kahrel

 

Unfortunately. 

 

I just tried to test all possible situations. 

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

User HAVE to be in "Page tool" mode BEFORE he starts changing selected pages

 

You can script the tool selection.

 
app.toolBoxTools.currentTool = UITools.PAGE_TOOL;

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

@rob day

 

Isn't using invoke() the same?

 

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

Isn't using invoke() the same?

 

Not exactly, currentTool is read/write, so you can get and set the tool

 

//get the current tool
var ct = app.toolBoxTools.currentTool
$.writeln(ct)

//set the current tool
app.toolBoxTools.currentTool = UITools.PAGE_TOOL;

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 ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

LATEST

@rob day

 

Thanks for the clarification. 

 

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