Skip to main content
Known Participant
January 25, 2010
Answered

add a Suffix to all paragraph and character styles +

  • January 25, 2010
  • 2 replies
  • 1705 views

As the title says, first I want to add a Suffix to all paragraph and character styles:

Heading 1 = Heading 1_p

bold = bold_p

Also if possible replace the space with a underscore:

Heading 1 = Heading_1_p

Chapter Heading 1 = Chapter_Heading 1_p

Not sure if this need one script or two?

Any help would be fantastic.

Cheers

This topic has been closed for replies.
Correct answer Shonkyin-CF145T

Or use below code for replace all spaces with "_"

For Paragraph Styles:

myStyles=myDoc.paragraphStyles;

for (oneStyle=2;oneStyle<myStyles.length;oneStyle++)

{

myStyles[oneStyle].name= myStyles[oneStyle].name.replace (/ /g, "_") + "_p";

}

For Character Styles:

var mycStyleslen = myDoc.characterStyles.length;

for (a=1; a<mycStyleslen; a++)

{

myDoc.characterStyles.name =  myDoc.characterStyles.name.replace (/ /g, "_") + "_p";

}

Shonky

Inspiring
January 25, 2010

For Paragraph Styles:

myStyles=myDoc.paragraphStyles;

for (oneStyle=2;oneStyle<myStyles.length;oneStyle++)

{

myStyles[oneStyle].name= myStyles[oneStyle].name + "_p";

}

For Character Styles:

var mycStyleslen = myDoc.characterStyles.length;

for (a=1; a<mycStyleslen; a++)

{

myDoc.characterStyles.name =  myDoc.characterStyles.name + "_p";

}

Shonky

Known Participant
January 25, 2010

Thank you very much Shonkyin , I only just had time to make a coffee! super fast!!!

Just need to work out how to replace a space with a _ ?

Heading 1 = Heading_1_p

Chapter Heading 1 = Chapter_Heading 1_p

Inspiring
January 25, 2010

For Paragraph Styles:

myStyles=myDoc.paragraphStyles;

for (oneStyle=2;oneStyle<myStyles.length;oneStyle++)

{

myStyles[oneStyle].name= myStyles[oneStyle].name.replace (" ", "_") + "_p";

}

For Character Styles:

var mycStyleslen = myDoc.characterStyles.length;

for (a=1; a<mycStyleslen; a++)

{

myDoc.characterStyles.name =  myDoc.characterStyles.name.replace (" ", "_") + "_p";

}

Shonky

Inspiring
January 25, 2010

For Paragraph Styles:

myStyles=myDoc.paragraphStyles;

for (oneStyle=2;oneStyle<myStyles.length;oneStyle++)

{

myStyles[oneStyle].name= myStyles[oneStyle].name + "_p";

}

For Character Styles:

var mycStyleslen = myDoc.characterStyles.length;

for (a=1; a<mycStyleslen; a++)

{

myDoc.characterStyles.name =  myDoc.characterStyles.name + subfixcharastyle;

}

Shonky