Skip to main content
Techi_Panda
Inspiring
November 16, 2009
Answered

Delete all character styles and preserve formatting

  • November 16, 2009
  • 1 reply
  • 1649 views

Hi scripters

I need to delete all the character style using preserve formatting option  in my document.

how can i do this, with this i have started,

myDoc = app.activeDocument;

for(var j=0; myDoc.characterStyles.length>j; j++)

{

//

}

thanks in advance

regards

a r u l

This topic has been closed for replies.
Correct answer interesting_Flower157F

Hi scripters below is my code, I am trying to delete all the character styles except only three, this works fine but the while loop is not ending, my indesign hanging how to quite the loop

myDoc = app.activeDocument;

chsl=0;

var chsl = myDoc.characterStyles.length;
do
{
for(var j=1; myDoc.characterStyles.length>j; j++)

{
myDoc.characterStyles.remove();

}

}

while(chsl=3);

thnks in advance


When removing items, always loop backwards (j--) so your references stays valid.

1 reply

Harbs.
Brainiac
November 16, 2009

myDoc.characterStyles.remove();

Techi_Panda
Inspiring
November 16, 2009

Hi Harbs

thanks for your code I done that my problem is i want to preserve formatting for deleted items.

thnak u

Techi_Panda
Inspiring
November 16, 2009

Hi scripters below is my code, I am trying to delete all the character styles except only three, this works fine but the while loop is not ending, my indesign hanging how to quite the loop

myDoc = app.activeDocument;

chsl=0;

var chsl = myDoc.characterStyles.length;
do
{
for(var j=1; myDoc.characterStyles.length>j; j++)

{
myDoc.characterStyles.remove();

}

}

while(chsl=3);

thnks in advance