3 Replies Latest reply on Jun 23, 2009 7:27 PM by Karl Grob

    How to insert a paragraphStyle into a paragraphStyleGroup?

    Karl Grob

      First: I am new to JavaScript.

       

      I'm tying to insert a existing (and renamed) paragraphStyle into a newly created paragraphStyleGroup. I couldn't find any example and tried different wys, but nothing worked. It is absolutely essential that the existing pStyle is moved (no copy etc.). The formatted Text exists already and should not be changed.

       

      Renaming: works

      Creation of StyleGroup: works

      Moving: the maximum I achieved was the creation of a new Format within the group.

       

      I'll be grateful for any help.

      Thanks

      Karl Grob

       

      // Aendert die Absatzstilformatnamen und ordnet sie in Gruppen

       

      renParaStyle("HK_ABasis", "HK_Basisabsatz", "Basisgruppe")

       

      function renParaStyle (myOldName, myNewName, myGroupName)

      {

      var myDoc =app.activeDocument;

      var myPara = myDoc.paragraphStyles.item(myOldName);

      var myGroup = myDoc.paragraphStyleGroups.item(myGroupName);

       

      if (myPara != undefined)

      {

      try

      {

      myPara.name = myNewName;

      }

      catch (e) {}

       

       

      try

      {

      myGroup = myDoc.paragraphStyleGroups.add({name:myGroupName});

      }

      catch (e) {}

      try

      {

      //

      // How to insert myPara into myGroup?

      }

      catch (e) {}

      }

      }