Reply To: Changing the paragraph style of the NEXT paragraph using Find or GREP

Home Page / Forums / General InDesign Topics (CLOSED) / Changing the paragraph style of the NEXT paragraph using Find or GREP / Reply To: Changing the paragraph style of the NEXT paragraph using Find or GREP

#60763

… Here is a script that does just that. Warning: it may change more than you want, and it's hard to see what it changed! Uncomment the fill-with-color lines if you need to know where the changes occurred (and run on a copy).

indentStyle = “Body-Indent”;
noIndentStyle = “Body-No Indent”;

if (app.documents.length > 0 && app.selection.length == 1 && app.selection[0].hasOwnProperty(“baseline”))
{
story = app.selection[0].parentStory.paragraphs;
lastStyle = null;
for (i=0; i<story.length; i++)
{
// Do we need to change?
if (story[i].appliedParagraphStyle.name == indentStyle ||
story[i].appliedParagraphStyle.name == noIndentStyle)
{
// Do we want an indent?
if ((lastStyle == indentStyle || lastStyle == noIndentStyle))
{
lastStyle = indentStyle;
if (story[i].appliedParagraphStyle.name == noIndentStyle)
{
story[i].appliedParagraphStyle = indentStyle;
// story[i].fillColor = “Red”;
}
} else if (!(lastStyle == indentStyle || lastStyle == noIndentStyle))
{
lastStyle = noIndentStyle;
if (story[i].appliedParagraphStyle.name == indentStyle)
{
lastStyle = story[i].appliedParagraphStyle = noIndentStyle;
// story[i].fillColor = “Green”;
}
}
} else
{
lastStyle = null;
}
}
}

This article was last modified on October 14, 2011

Comments (0)

Loading comments...