Indesign script to replace paragraph style


I am using ID CC 2014 on a Mac and there's a huge file with several hundred pages where I need to delete a certain paragraph style replacing it with another. Say there's a para style called "style-1". When I delete it from the para styles panel, it asks me to provide another style to take its place for pieces of text currently styled as "style-1". Here, I add, say, "style-2" to take its place. Is there any way to automate the process using a script? I tried studying the FindTextPreference JS class but it doesn't seem to have the properties we might need in this case. Any tips?

7/8/2015 4:35:00 AM

Accepted Answer

Okay, I finally figured out the answer myself and am posting it here for the benefit of others. The trick is to call the remove method of the ParagraphStyle class (more accurately, the paragraph style being removed). The syntax is:


In this syntax, the New_Style argument is optional. Thus, for my example, the correct code would be:

var old = app.activeDocument.paragraphStyles.itemByName("style-1"); var new = app.activeDocument.paragraphStyles.itemByName("style-2"); old.remove(new);

More details on the ParagraphStyle class can be found at

7/8/2015 8:56:00 AM