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

Obi-wan Kenobi
Legend
August 7, 2014

Hi Kai,

I do it with a little grep search. 

Obi-wan Kenobi
Legend
August 18, 2014

What could be a reason fo this one? "Search a paras group (in sequence) with the same style and the same manual bullet."

I would say, the script should cover 3 topics:

1. Search a paras group (in sequence) with the same style (no manual bullet used but possibly auto-numbering)

2. Search a paras group (in sequence) with the same manual bullet

3. Search a paras group (in sequence) that has already a local real bulleted list applied

I will try to figure that out, but give me some time


What I mean by:

Search a paras group (in sequence) with the same style and the same manual bullet


When we import a Word file, we can have several paras groups with the same bullet BUT, in the ID Layout, we can choose to use several different "Style 0" [Style 0a, Style 0b …] to format these paras, like in this sample:


Before script:


After script:


A good idea to be included too:


You search a para style "Style 0" with manual bullet and you apply the 3 para styles deleting the manual bullet replacing it by a object placed in a library. As:



In fact, when I imagine a script, I try to include in it things I can do with it. That always makes it more complex, but as I have ideas, I'm not satisfied!


That said, nothing forces you to continue! I have other extensions in mind such as nesting multiple levels of styles!