4 Replies Latest reply on May 25, 2013 12:47 AM by Laubender

    Checking whether Paragraph Style name exists in document


      In JS, I have an object of shorthand keys and paragraph style names, like so:


        var styles = {

           BDY: "Body Text",

            HED1: "Headline 1",

           HED2: "Headline 2",




      Is there a way to quickly check whether a name is present in the document, without having to loop through all the styles in the document?


      I tried something like:


      var docStyles = doc.paragraphStyles;    

      for ( var key in styles ) {

                if ( typeof docStyles[ styles[key] ] == "undefined" ) ...



      But the invalid name still is defined, it's still an instanceof PargraphStyle, but of course, if I try to use it later in the script, I get an error.


      Any thoughts, or do I have to call allParagraphStyles, and loop through that to figure out if the name matches one of those in the list?