Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Move paragraph styles from style group

Contributor ,
Jul 07, 2015 Jul 07, 2015

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){}

}

Screen shot 2015-07-07 at 2.02.08 PM.png

Screen shot 2015-07-07 at 2.02.26 PM.png

TOPICS
Scripting
874
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jul 07, 2015 Jul 07, 2015

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

Translate
People's Champ ,
Jul 07, 2015 Jul 07, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 07, 2015 Jul 07, 2015

Hi,

Thank you... Its working...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 08, 2015 Jul 08, 2015
LATEST

Hi,

     If i move the same style name (Paragraph Style 1) from style group its throwing the below error.

Screen shot 2015-07-08 at 1.55.47 PM.png

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

Screen shot 2015-07-08 at 2.08.37 PM.png

How to overwrite the style using script???

- Sudha K

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines