Reply To: Script to insert grep style in all Paragraph styles

#60804

Yes, it is. Here's an example:

Main();

function Main() {
var doc = app.activeDocument,
parStyles = doc.allParagraphStyles,
charStyle = doc.characterStyles.item(“Figure numbers”),
parStyle, i, grepStyle;

if (!charStyle.isValid) doc.characterStyles.add({name:”Figure numbers”, fontStyle:”Bold”});

for (i = 1; i < parStyles.length; i++) {
parStyle = parStyles[i];
grepStyle = parStyle.nestedGrepStyles.add();
grepStyle.grepExpression = “d+”;
grepStyle.appliedCharacterStyle = charStyle;
}
}

The script adds a grep style to every paragraph style including styles in groups.

This article was last modified on October 18, 2011

Comments (0)

Loading comments...