Answered
Peter KahrelCorrect answer
Community Expert
August 9, 2024
Here's a script I use to break a story on instances of a paragraph style. It assumes that the paragraph is set to start on the next page or frame.
To use it, place the cursor in the paragraph style (the one applied to 'New Articles' in your sample) and run the script. As always, keep a copy of the document in a safe place.
//DESCRIPTION: Split a story on the selected paragraph style
(function () {
var styleName = app.selection[0].appliedParagraphStyle.name;
var story = app.selection[0].parentStory;
var p = story.paragraphs.everyItem().getElements();
var frame;
for (var i = p.length-1; i >= 1; i--) {
if (p[i].appliedParagraphStyle.name === styleName) {
frame = p[i].parentTextFrames[0];
frame.previousTextFrame = null;
story.insertionPoints.itemByRange (p[i].index, story.length)
.move (LocationOptions.AFTER, frame.insertionPoints[0]);
}
}
}());
