Skip to main content
Known Participant
February 1, 2023
Answered

Script to apply more than paragraph style on certain range of pages Not all

  • February 1, 2023
  • 1 reply
  • 4349 views

Hi 

I have an indesign file that contain 3 different designs distrubuted along 100 pages , I have 2 paragraph styles for each design

I want a script to apply certain paragraph styles on text frames of certain pages Not All pages in the File

 

Ex : Paragraph style  (1)  from page 1 to 10 , Paragraph style (2) from page 1 to  10

       Paragraph style (3)  from page 11 to 15 , Paragraph style (4)  from page 11 to 15

 

Can I do that by a script ???

 

       

 

This topic has been closed for replies.
Correct answer FRIdNGE
/*
by FRIdNGE, Michel Allio [01/02/2023]
*/

var myDoc = app.activeDocument,
myPages = myDoc.pages;
// "O" is the first page; "4" is the 5st page.
for ( var p = 0; p < 4; p++ ) {
    var myTFrames = myPages[p].textFrames;
    // "myTFrames[1]" is the first text frame created on the page;
    // "myDoc.paragraphStyles.item("1")" is the name ("1") of the para style to be applied;
    // "myTFrames[0]" is the second text frame created on the page;
    // "myDoc.paragraphStyles.item("2")" is the name ("2") of the para style to be applied;
    myTFrames[1].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.item("1");
    myTFrames[0].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.item("2");
}
alert( "Done!…" )

… So if you want "pages 1-4", write this line:

 

for ( var p = 0; p < 4; p++ ) {
 

… if you want "pages 5-9", write this line:

 

for ( var p = 4; p < 9; p++ ) {
 

(^/)

1 reply

Known Participant
February 1, 2023

Any Help Here

FRIdNGE
February 1, 2023

Hi,

 

Yes, you can do it by Script (with more infos)!

 

(^/)  The Jedi

Known Participant
February 1, 2023

Thanks for Your Reply

After your permission can you write this script and post it here ?