Copy link to clipboard
Copied
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?
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 =
...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
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; }
}
Copy link to clipboard
Copied
how do i define this script to document
Copy link to clipboard
Copied
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; }
}
Copy link to clipboard
Copied
You are an amazing person!
I placed the code in the program and it worked. I have a small request. As I have shown in the attachment, it fills the text area with color, I just want to change the color of the text. How can I write this in code? The background will actually be none, I will replace the text color with red, blue, orange, yellow .... + is it possible to add white stroke code? stroke thickness as 15 pt.
Thank you so much.
Copy link to clipboard
Copied
Something like this. You'll need to add the other swatches and other conditional statements. I agree with Willi that using Object Styles in the first place would have been the correct approach for the task.
var d = app.activeDocument;
var ps = d.pages;
var red = d.swatches.itemByName("RGB Red");
var blue = d.swatches.itemByName("RGB Blue");
var white = d.swatches.itemByName("[Paper]");
for (var i = 0; i < ps.length; i++) {
if (i < ps.length/2) {
ps[i].textFrames[0].parentStory.fillColor = red;
ps[i].textFrames[0].parentStory.strokeColor = white;
ps[i].textFrames[0].parentStory.strokeWeight = "15 pt";
} else if (i > ps.length/2 && i < ps.length * 2 / 3) {
ps[i].textFrames[0].parentStory.fillColor = blue;
ps[i].textFrames[0].parentStory.strokeColor = white;
ps[i].textFrames[0].parentStory.strokeWeight = "15 pt";
} else {
//etc.
}
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
}
}
Copy link to clipboard
Copied
thank you very much, you are amazing my friend
Copy link to clipboard
Copied
Sorry change 15 px to 15 pt under the sw variable
Copy link to clipboard
Copied
yes yes i noticed i changed it. You saved me a big job. Thanks again