1 Reply Latest reply on Mar 14, 2008 9:27 AM by Peter Kahrel

    Wish to check if a style exists; create it if it doesn't exist.

    Tom Tomasko Level 1
      Hello,

      I am trying to write a script that will check to see if a style already exists in a document. If it does, fine, I'll use it. If it does not, then I want to create the style. The following script errors out, telling me there is an invalid parameter.

      if(document.objectStyles.item().name !== myCharStyle){
      var myCharStyle = myDoc.characterStyles.add({name:"myCharStyle"});
      }

      I have tried using the try/catch function as it is written in Adobe's InDesign Scripting Guide: JavaScript but this also just errors out.

      Thanks,
      Tom