1 Reply Latest reply on Apr 17, 2017 4:27 AM by BEGINNER_X

    Move Paragraph Styles back to their existing Groups

    BEGINNER_X Level 3

      HI ALL,

       

      Request:

       

      1. Move Paragraph Styles from paragraph styles group to normal   //working fine

       

      2. Import XML into active doc   //working fine

       

      3. Again Move normal paragraph Styles to the same existing Groups  //Need HELP

       

       

       

      Trying below code:

      Move Paragraph Styles from paragraph styles group to normal

       

      //Task 1:
      var myDoc = app.activeDocument;  
      
      myGroup_Name_Array = [];
      myPstyle_Name_Array = [];
      
      var myPStyle_Groups = app.activeDocument.paragraphStyleGroups;
      
      for(p=0; p<myPStyle_Groups.length; p++)
      {
          myGroup_Name_Array.push(myPStyle_Groups[p].name)
          var myGroups_Pstyles = myPStyle_Groups[p].paragraphStyles.everyItem().getElements();
          for(g=0; g<myGroups_Pstyles.length; g++)
          {
              myPstyle_Name_Array.push(myGroups_Pstyles[g].name)
              myGroups_Pstyles[g].move(LocationOptions.AT_END, myDoc)   //Move styles from Groups
              
              }
          }
      
      
      //Task 2:
      
      //Import XML to indesign  //working fine
      
      
      //Task 3: (Need Help)
      
      //Again Move normal paragraph Styles to the same existing Groups
      

       

       

      Thanks & Regards

      Siraj

        • 1. Re: Move Paragraph Styles back to their existing Groups
          BEGINNER_X Level 3

          Hi All,

           

          Got the output...

           

          var myDoc = app.activeDocument;  
          myTemp = []
          myTemp_Parent = [];
          
          var myPStyle_Groups = app.activeDocument.paragraphStyleGroups;
          
          for(p=0; p<myPStyle_Groups.length; p++)
          {
              var myGroups_Pstyles = myPStyle_Groups[p].paragraphStyles.everyItem().getElements();
              for(g=0; g<myGroups_Pstyles.length; g++)
              {
                  
                myTemp.push(myGroups_Pstyles[g])
                myTemp_Parent.push(myGroups_Pstyles[g].parent)
          
                  myGroups_Pstyles[g].move(LocationOptions.AT_END, myDoc)   //Move styles from Groups
                  
                  }
              }
          
          for(x=0; x<myTemp.length; x++){
              alert(myTemp[x].name)
              myTemp[x].move(LocationOptions.atEnd, myTemp_Parent[x])
              }
          

           

          Thanks

          Siraj