Copy link to clipboard
Copied
Hi
I have a multi-page document with a single text frame split into two columns on each page. I would like to place a column rule on every page. I have set up an Object Style that will do this. Is there any way I can apply that style to all of my pages, not just one at a time?
1 Correct answer
Hello @J5FC1,
Give this script a try, just change "Test" to the name of your Object Style...
function main() {
doc = app.documents[0];
for(var i=0;i<doc.pages.length;i++){
var myPageItems = doc.pageItems.everyItem().getElements();
for(var i=0;i<myPageItems.length;i++){
if (myPageItems[i] instanceof TextFrame){
myPageItems[i].applyObjectStyle(doc.objectStyles.itemByName("Test"));
}
}
}
}
app.doScript(main, ScriptLanguage.JAVASCR
...
Copy link to clipboard
Copied
Hello @J5FC1,
Give this script a try, just change "Test" to the name of your Object Style...
function main() {
doc = app.documents[0];
for(var i=0;i<doc.pages.length;i++){
var myPageItems = doc.pageItems.everyItem().getElements();
for(var i=0;i<myPageItems.length;i++){
if (myPageItems[i] instanceof TextFrame){
myPageItems[i].applyObjectStyle(doc.objectStyles.itemByName("Test"));
}
}
}
}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Do Script');
You can also try this free script "Apply Object Style to All Text Containers in a Story"
https://www.id-extras.com/apply-object-style-to-all-text-containers-in-a-story-free-script/
Regards,
Mike
Copy link to clipboard
Copied
Thanks Mike. I wasn't able to get your script to work, but the "Apply Object Style to All Text Containers in a Story" has done the trick.
Copy link to clipboard
Copied
Work with primary textframes. You can put such one with this text frame object style on the master/parent. Apply this master/parent to the pages where you need this style.
If you don not work with primary text frames it will not work.
Copy link to clipboard
Copied
Thanks Willi,
I've not used Primary Text Frames before, but can see the value for future projects

