Reply To: Automatically set paragraph style sheet

Home Page / Forums / General InDesign Topics (CLOSED) / Automatically set paragraph style sheet / Reply To: Automatically set paragraph style sheet

#86968
Ari Singer
Member

Try this:

var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences= null;
app.findGrepPreferences.findWhat = "$";
app.findGrepPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item("Day entries");
var story = myDoc.findGrep()[0].parentStory;
var found = story.findGrep(true);
for (var i =0; i < found.length; i++) {
	var para1 = found[i].paragraphs.firstItem();
	var para2 = para1.paragraphs[-1].insertionPoints[-1].paragraphs[0];
	if (para2.appliedParagraphStyle == myDoc.paragraphStyles.item("Date Headings"))
		para1.appliedParagraphStyle = myDoc.paragraphStyles.item("Day entries LAST");
	}


This works by finding any paragraph that has the regular paragraph entry applied, but that the paragraph after that has the new date paragraph style applied.

This article was last modified on July 28, 2016

Comments (0)

Loading comments...