Skip to main content
Participant
August 7, 2014
解決済み

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

  • August 7, 2014
  • 返信数 1.
  • 5236 ビュー

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?

このトピックへの返信は締め切られました。
解決に役立った回答 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

Kai Rübsamen
Kai Rübsamen解決!
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. 

idjev
Known Participant
March 8, 2018

Ah, this writing for the styles was not intended, since I saved the names already in the variables at the beginning of the script.

Limitation: This will not work with paragraph styles in groups at the moment and: What if there is no list instead there are typed bullets followed by a tab. So a little GREP-search could be included. Your idea with the UI sounds interesting. Since I have no idea how to do this and since I never built a UI before, this could be my little first one ;-) In the meantime the corrected version.

var bulletStyle = "allBullets", 

    firstBulletStyle = "firstBullet", 

    lastBulletStyle = "lastBullet"; 

 

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; 

        // whole list 

        allParas.everyItem().appliedParagraphStyle = bulletStyle; 

        // first bullet 

        allParas[0].appliedParagraphStyle = firstBulletStyle; 

        // last bullet 

        allParas[allParas.length-1].appliedParagraphStyle = lastBulletStyle;   

}   

     

app.findGrepPreferences = app.changeGrepPreferences = null;   


CC 2018 not working :  is it possible update Thanks