Skip to main content
Known Participant
March 1, 2017
Answered

How to select a section text in middle of paragraphstyle A and paragraphstyle B?

  • March 1, 2017
  • 2 replies
  • 429 views

I want to split some texts by paragraphstyle,how to select a section text in middle of  paragraphstyle A and paragraphstyle B?

Please suggest me how to do this with javascript.

Thanks,

Goldbridge

This topic has been closed for replies.
Correct answer Trevor:

How about

Pseudo Code

... findPreferences ... = style1

myStyle1Finds = myStory.findText()

... findPreferences ... = style2

myStyle2Finds = myStory.findText()

loop .. i

a = myStyle1Finds.characters[-1].index + 1;

b = myStyle2Finds.characters[0].index - 1;

a bit of checking here to see that b is > a

then something close to

a = myStory.characters.paragraphs[0];

b = myStory.characters.paragraphs[0];

// paragraphs in between are

myStory.paragraphs.itemByRange(a,b).fillColor = "None" (well you might want to pick some other properties and values).

HTH

Trevor

Trevor:
Trevor:Correct answer
Legend
March 1, 2017

How about

Pseudo Code

... findPreferences ... = style1

myStyle1Finds = myStory.findText()

... findPreferences ... = style2

myStyle2Finds = myStory.findText()

loop .. i

a = myStyle1Finds.characters[-1].index + 1;

b = myStyle2Finds.characters[0].index - 1;

a bit of checking here to see that b is > a

then something close to

a = myStory.characters.paragraphs[0];

b = myStory.characters.paragraphs[0];

// paragraphs in between are

myStory.paragraphs.itemByRange(a,b).fillColor = "None" (well you might want to pick some other properties and values).

HTH

Trevor

Known Participant
March 2, 2017

Dear Trevor,that's great,thank you!

Obi-wan Kenobi
Legend
March 1, 2017

Hi! Screenshots please!

(^/)