Skip to main content
Inspiring
January 10, 2017
Answered

find applied paragraph style

  • January 10, 2017
  • 1 reply
  • 1309 views

Hi Guys,

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

if ( (paras

.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.paragraphs.everyItem().getElements();
        
       for ( p = paras.length; p >= 0;  p-- ) {
          
          if ( (paras

.appliedParagraphStyle).name.toLowerCase() == "heading 1" ) {
              
               paras

.convertBulletsAndNumberingToText(); // convert the heading 1 paragraph style numbers to text
              
              
               }

This topic has been closed for replies.
Correct answer tpk1982

try this

var myDoc = app.activeDocument;  

var paras = myDoc.stories.everyItem().paragraphs.everyItem().getElements();  

for (var i = 0; i < paras.length; i++) {  

    myParaSel = paras;  

        if (myParaSel.appliedParagraphStyle.name.toLowerCase() == "heading 1" ) { 

        myParaSel.convertBulletsAndNumberingToText(); 

        }  

Remember your style should not be inside paragraph style group

HTH

1 reply

tpk1982
tpk1982Correct answer
Legend
January 10, 2017

try this

var myDoc = app.activeDocument;  

var paras = myDoc.stories.everyItem().paragraphs.everyItem().getElements();  

for (var i = 0; i < paras.length; i++) {  

    myParaSel = paras;  

        if (myParaSel.appliedParagraphStyle.name.toLowerCase() == "heading 1" ) { 

        myParaSel.convertBulletsAndNumberingToText(); 

        }  

Remember your style should not be inside paragraph style group

HTH