Skip to main content
Participant
November 28, 2022
Answered

Adding Column Rules to multiple connected text frames

  • November 28, 2022
  • 2 replies
  • 550 views

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?

This topic has been closed for replies.
Correct answer Mike Bro

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

2 replies

Willi Adelberger
Community Expert
Community Expert
November 29, 2022

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.

J5FC1Author
Participant
November 30, 2022

Thanks Willi,

I've not used Primary Text Frames before, but can see the value for future projects

Mike BroCorrect answer
Legend
November 29, 2022

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

J5FC1Author
Participant
November 30, 2022

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.