Skip to main content
Known Participant
March 3, 2013
Answered

apply paragraphStyles Inbetween paragraphStyles

  • March 3, 2013
  • 1 reply
  • 1447 views

Hi Forum,

this is the script im trying to change paragraphStyles[BodyText_Indent] of  paragraphs between "bullet" style and "bullet_2" style.

only one instance is happenning after "bullet" style and before "bullet_2" style.

please help!...

myDoc = app.activeDocument;

for (j = myDoc.stories.length - 1; j >= 0; j--) {

    myStory = myDoc.stories.item(j);

    myParas = myStory.paragraphs;

//    if (myParas.length > 5) {

        for (i = 0; i <myStory.paragraphs.length;  i++) {

            if (myStory.paragraphs.appliedParagraphStyle == myDoc.paragraphStyleGroups.item("Bullet").paragraphStyles.item("Bullet"))

                myStory.paragraphs[i+1].appliedParagraphStyle = myDoc.paragraphStyleGroups.item("Bullet").paragraphStyles.item("Bullet_Indent")

               

                if (myStory.paragraphs.appliedParagraphStyle == myDoc.paragraphStyleGroups.item("Bullet").paragraphStyles.item("Bullet_2"))

                myStory.paragraphs[i-1].appliedParagraphStyle = myDoc.paragraphStyleGroups.item("Bullet").paragraphStyles.item("Bullet_Indent");

}}

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

My idea is:

- use 'bullet' as a textFindPreferences.appliedParagraphStyle set;

- story.findText() will create an array (let say StartArr) of those paragraphs;

- use 'bullet2' as a textFindPreferences.appliedParagraphStyle set;

- story.findText() will create an array (let say EndArr) of those paragraphs;

we can assume both arrays are with same length, I think.

- you could iterate through those arrays and catch a "start" and "end" paragraphs.

- if 'start' paragraph would be a myStory.paragraphs.nextItem(StartArr[0].paragraphs[-1])

     ==> 'end' paragraph would be:  myStory.paragraphs.previousItem(EndArr[0].paragraphs[0]);

- so your 1st part of text could be a part of story defined by
          story.paragraphs.itemByRange(start,end).texts[0]

and so on...

watch this discussion:

http://forums.adobe.com/thread/1162582?tstart=0

rgds

1 reply

Jump_Over
Jump_OverCorrect answer
Legend
March 3, 2013

Hi,

My idea is:

- use 'bullet' as a textFindPreferences.appliedParagraphStyle set;

- story.findText() will create an array (let say StartArr) of those paragraphs;

- use 'bullet2' as a textFindPreferences.appliedParagraphStyle set;

- story.findText() will create an array (let say EndArr) of those paragraphs;

we can assume both arrays are with same length, I think.

- you could iterate through those arrays and catch a "start" and "end" paragraphs.

- if 'start' paragraph would be a myStory.paragraphs.nextItem(StartArr[0].paragraphs[-1])

     ==> 'end' paragraph would be:  myStory.paragraphs.previousItem(EndArr[0].paragraphs[0]);

- so your 1st part of text could be a part of story defined by
          story.paragraphs.itemByRange(start,end).texts[0]

and so on...

watch this discussion:

http://forums.adobe.com/thread/1162582?tstart=0

rgds

shilpa25Author
Known Participant
March 3, 2013

thanks jumpover,

but im little bit confused....

ill try...

thanks jumpover, thanks jumpover,