Skip to main content
Participant
August 7, 2014
Answered

Finding and replacing Paragraph Style of last line in a bulletted list?

  • August 7, 2014
  • 1 reply
  • 5236 views

Hi,

I'm wondering if there's a way (or a script out there) to automate finding the last item of a bulletted list and apply a paragraph style? I'm dealing with multiple, hundred-page documents with tons of bulletted lists, and currently I'm applying a paragraph style to each of these in order to increase the space below the list and the top of the next paragraph.

Suggestions?

This topic has been closed for replies.
Correct answer Kai Rübsamen

It’s not clear to me, if the bullets are formatted at this time or how you indentify them.

But try the following:

app.findGrepPreferences = app.changeGrepPreferences = null; 

app.findGrepPreferences.properties = { bulletsAndNumberingListType: ListType.BULLET_LIST };

var allFounds = app.findGrep();

for ( var i = 0; i < allFounds.length; i++ ) {

    var curFound = allFounds;

    var allParas = curFound.paragraphs;

    var nParas = allParas.length;

    allParas[nParas-1].appliedParagraphStyle = "bulletLast";

}

app.findGrepPreferences = app.changeGrepPreferences = null; 

–Kai

1 reply

Kai Rübsamen
Kai RübsamenCorrect answer
Participating Frequently
August 7, 2014

It’s not clear to me, if the bullets are formatted at this time or how you indentify them.

But try the following:

app.findGrepPreferences = app.changeGrepPreferences = null; 

app.findGrepPreferences.properties = { bulletsAndNumberingListType: ListType.BULLET_LIST };

var allFounds = app.findGrep();

for ( var i = 0; i < allFounds.length; i++ ) {

    var curFound = allFounds;

    var allParas = curFound.paragraphs;

    var nParas = allParas.length;

    allParas[nParas-1].appliedParagraphStyle = "bulletLast";

}

app.findGrepPreferences = app.changeGrepPreferences = null; 

–Kai

Participant
August 7, 2014

YES! Kai you are awesome, this is perfect and will save so many hours!!

Thank you!!!!