1 Reply Latest reply on Jan 10, 2017 3:14 AM by tpk1982

    find applied paragraph style

    jakec88782761 Level 1

      Hi Guys,

       

      This script used to work and now it says this line is undefined...

       

      if ( (paras[p].appliedParagraphStyle).name.toLowerCase() == "heading 1" ).

       

       

      this is the part of the script that's failing, what is going wrong?

       

      var newDoc = app.activeDocument,

      frame = newDoc.textFrames.everyItem().getElements();
            

            
             for ( var c = 0; c < frame.length; c++ ) {
            
             var paras = frame[c].paragraphs.everyItem().getElements();
              
             for ( p = paras.length; p >= 0;  p-- ) {
                
                if ( (paras[p].appliedParagraphStyle).name.toLowerCase() == "heading 1" ) {
                    
                     paras[p].convertBulletsAndNumberingToText(); // convert the heading 1 paragraph style numbers to text
                    
                    
                     }

        • 1. Re: find applied paragraph style
          tpk1982 Level 4

          try this

           

          var myDoc = app.activeDocument;   
          var paras = myDoc.stories.everyItem().paragraphs.everyItem().getElements();   
          for (var i = 0; i < paras.length; i++) {   
              myParaSel = paras[i];   
                  if (myParaSel.appliedParagraphStyle.name.toLowerCase() == "heading 1" ) {  
                  myParaSel.convertBulletsAndNumberingToText();  
                  }   
          }  
          

           

           

          Remember your style should not be inside paragraph style group

           

          HTH