Copy link to clipboard
Copied
Hi,
I want to move paragraph styles from paragraph style group to paragraph style pallete. I am using the below code to do that. Styles from style group is moved to out but showing inside of the style group. So every item of paragraph style is return without moved style name. It taken the last paragraph style as style group.
test(app.activeDocument.paragraphStyleGroups);
alert(app.activeDocument.paragraphStyles.length + " - " + app.activeDocument.paragraphStyles.everyItem().name)
function test(sGrp)
{
//try{
for(var i = sGrp.length - 1; i >=0; i--)
{
cstyleGrp = sGrp;
for(var j = cstyleGrp.paragraphStyles.length - 1; j >= 0; j--)
{
var cstylGrpStyle = cstyleGrp.paragraphStyles
cstylGrpStyle.move (LocationOptions.AT_END, app.activeDocument.paragraphStyles[app.activeDocument.paragraphStyles.length-1]);
//cstylGrpStyle.move (LocationOptions.AT_END, null);
//cstylGrpStyle.move (LocationOptions.AFTER, app.activeDocument.paragraphStyles[0]);
}
if(cstyleGrp.paragraphStyleGroups.length > 0)
{
test(cstyleGrp.paragraphStyleGroups);
}
}
//}catch(e){}
}


You can get very buggy behaviour if you're not careful with moving paragraph styles!
Anyway, the correct way to move a paragraph style is like this (you have to modify the code below so that p becomes a reference to a real paragraph style):
d = app.activeDocument;
p = /*some paragraph style in a para-style group*/
// The following line move paragraph style p out of its group and into the main list of paragraph styles in document d
p.move(LocationOptions.UNKNOWN, d);
HTH
Copy link to clipboard
Copied
You can get very buggy behaviour if you're not careful with moving paragraph styles!
Anyway, the correct way to move a paragraph style is like this (you have to modify the code below so that p becomes a reference to a real paragraph style):
d = app.activeDocument;
p = /*some paragraph style in a para-style group*/
// The following line move paragraph style p out of its group and into the main list of paragraph styles in document d
p.move(LocationOptions.UNKNOWN, d);
HTH
Copy link to clipboard
Copied
Hi,
Thank you... Its working...
Copy link to clipboard
Copied
Hi,
If i move the same style name (Paragraph Style 1) from style group its throwing the below error.

If i move manually its brings the warning dialog as shown below.

How to overwrite the style using script???
- Sudha K
Find more inspiration, events, and resources on the new Adobe Community
Explore Now