Skip to main content
alpera10488582
Participating Frequently
June 21, 2022
Answered

Selecting text areas on multiple pages

  • June 21, 2022
  • 15 replies
  • 1571 views

Is there a way to select all text fields in a multi-page indd document? For cases where text fields are used without linking. Separately created text fields. For example, in a 10-page document, there are 10 independent text fields and if we want to select them like cmd+A, how can we achieve it?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer brian_p_dts

Greetings again,
That's exactly what I wanted, man. I can change the color names etc in my Swatches panel. But I think I'm making a mistake while multiplexing the code. You've already done a color change in 10 pages. How do I multiplex this? Likewise, I want to change the color every 10 pages. I have 5 main colors.

 

----------------------

 

var d = app.activeDocument;
var ps = d.pages;
var red = d.swatches.itemByName("RGB 01");
var blue = d.swatches.itemByName("RGB Blue");
for (var i = 0; i < ps.length; i++) {
if (i < 10) { ps[i].textFrames[0].parentStory.fillColor = red; }
else { ps[i].textFrames[0].parentStory.fillColor = blue; }
}

 

-----------------

 

can you multiplex through this code?

thank you for your help


I have no idea what multiplex means. But if you have five colors that you want to change every ten pages, then it would be: 

 

//put all five swatch names below; leave the quote marks around them, and keep the comma structure
var snames = ["RGB 01", "RGB Blue", "RGB Orange", "RGB Yellow", "RGB Pink"];
var d = app.activeDocument;
var ps = d.pages;
var papel = d.swatches.itemByName("[Paper]");
var sw = "15 px";
var ix, parStor;
for (var i = 0; i < ps.length; i+=10) {
   ix = i % 5;
   for (var j = 0; j < 10; j++) {
      try {
      parStor = ps[j + i].textFrames[0].parentStory;
      parStor.fillColor = d.swatches.itemByName(snames[ix]);
      parStor.strokeColor = papel;
      parStor.strokeWeight = sw;
      } catch(e) {} //we try/catch to handle out of bounds on page length
   }
}

 

 

15 replies

brian_p_dts
Community Expert
Community Expert
June 21, 2022

In your example of 10 pages, assuming only one text frame per page, and named swatches of RGB Red and RGB Blue. If more than one text frame per page, then yes, you need some way to identify them.

var d = app.activeDocument;
var ps = d.pages;
var red = d.swatches.itemByName("RGB Red");
var blue = d.swatches.itemByName("RGB Blue");
for (var i = 0; i < ps.length; i++) {
    if (i < 5) { ps[i].textFrames[0].fillColor = red; }
    else { ps[i].textFrames[0].fillColor = blue; }
}

 

alpera10488582
Participating Frequently
June 21, 2022

how do i define this script to document

brian_p_dts
Community Expert
Community Expert
June 21, 2022

Clarify what you mean. I've updated the script so that it will change the text frame on all pages in the front of the document, regardless of length, to red, and the back to blue. To run a script, read: https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/
Even with minimal coding knowledge, the script should be fairly easy to understand. For all pages in a given document, the first textframe on each page gets a fill color of RGB Red. All pages in the latter half of the document get a Fill Color of RGB Blue. If you need more conditional statements, you would use else if. I.e., else if (i < ps.length * 2 / 3 && i > ps.length / 3> ) { ... }

If you would like specific help, you need to ask specific questions and give specific answers. Others have asked good questions in this thread that merit a response so we can help you more effectively. 

var d = app.activeDocument;
var ps = d.pages;
var red = d.swatches.itemByName("RGB Red");
var blue = d.swatches.itemByName("RGB Blue");
for (var i = 0; i < ps.length; i++) {
    if (i < ps.length/2) { ps[i].textFrames[0].fillColor = red; }
    else { ps[i].textFrames[0].fillColor = blue; }
}

 

Community Expert
June 21, 2022

Adding to what Willi and Mark said:

It would help to know if there is a unique characteristic on the independent text frames you like to change.

Perhaps it's always the only one on the page that is independent?

Perhaps it always sits on a specially named layer?

Perhaps the text inside this frame is formatted with a paragraph style that never is used in other frames?

Something like that…

 

Then a script could visit every document page, identifies the text frame and changes the fill color.

And if we are at it: Is there a color scheme for the changes? There will be 50 color changes all over your document.

Or is it only a change from red to blue and back to red?

 

Regards,
Uwe Laubender
( Adobe Community Professional )

m1b
Community Expert
Community Expert
June 21, 2022

Hi @alpera10488582, you have tagged scripting on this post, and that might be a good way to go. You can target (not select, strictly speaking) text frames anywhere in the document but just need a way to reference them. If you only have 10 text frames in whole document it's easy. Or if the 10 text frames have a characteristic that sets them apart from all others, eg. Size or position, or label, or something about their contents. You get the idea.

 

But @Willi Adelberger's question is important, because depending on what you want to do with the 10 text frames, there might be better ways, eg. Giving them all an object style. 
- Mark

Willi Adelberger
Community Expert
Community Expert
June 21, 2022

You can select unthreaded text frames only on the same spread.

 

But tell us, what you want to do at the end, maybe another solution fits better for you.

alpera10488582
Participating Frequently
June 21, 2022

In a 1000 page document, I have an independent text field on each page. I want to change color every 20. Those between 1-20 are red, and those between 21-40 are blue. Actually, I'm looking for a shortcut to this.

Willi Adelberger
Community Expert
Community Expert
June 21, 2022

In such a case, I am sure you have worked with object and Paragraph styles. Change the styles and you have done it with some clicks. If not, you have learned, what object styles are for.