3 Replies Latest reply on Dec 10, 2012 7:32 AM by csm_phil

    Rename ParagraphStyle

    BEGINNER_X Level 3

      Hi All,

       

      Studying through "InDesignCS3_ScriptingGuide_JS".

       

      Requirement is:

       

      I want to add "A_" infront of  all paragraph styles.

       

      For example H1, H2, H3, TX....   means A_H1, A_H2, A_H3, A_TX etc.....

       

       

      Trying Code is:

       

      var myDocument = app.activeDocument

       

      var myPStyles = myDocument.paragraphStyles.everyItem().getElements()

       

      for(i=0; i<myPStyles.length; i++)

      {

       

      // alert(myPStyles[i].name) 

       

      //GIVE SOLUTION  


      myPStyles[i].name = myPStyles[i].name("A_"+"")

        

      }

       

       

      Please can anyone give solution for me.

       

       

      Thanks in advance

      BEGINNER

        • 1. Re: Rename ParagraphStyle
          csm_phil Level 4

          Hi BEGINNER_X

           

          I had modified your JS code.

           

          If you need brief explanation. Already, Jongware told to you keep to follow.

           

          http://forums.adobe.com/thread/1110879?tstart=0

          This clearly exposes your weakest point. You need to know basic Javascript before you can specifically write something for InDesign.

           

          The parts you highlight are plain, regular Javascript; nothing special. They are covered in any Javascript tutorial. Explaining them wouldn't take much time, but teching basic Javascript is not really the target of the InDesign scripting forum.

           

           

          var myDocument = app.activeDocument
          var myPStyles = myDocument.paragraphStyles.everyItem().getElements()
          for(i=2; i<myPStyles.length; i++)
          {
          myPStyles[i].name = "A_".concat(myPStyles[i].name);
          }
          

           

           

          thx,

          csm_phil

          • 2. Re: Rename ParagraphStyle
            BEGINNER_X Level 3

            Hi csm_phil,

             

            Thanks for your reply....

             

            Its working fine.

             

             

            With the help of yours (forum) i am learning javascript for the last 1 month. Forgive me if i ask any  basic question.

             

            I try to learn quickly.

             

            Thanks

            BEGINNER

            • 3. Re: Rename ParagraphStyle
              csm_phil Level 4

              Hi BEGINNER_X,

               

              If you get the answered question, please select the answer question or helpfull question, otherwise this thread is still open, try to follow this habit.

               

              All the best for your learning.

               

              thx,

              csm_phil