3 Replies Latest reply on Apr 23, 2015 8:14 AM by Jeppe Volander

    Paragraph Style selection and override

    Jeppe Volander

      Hello all,


      I desperately need your assistance.

      Im trying to write a script which creates 'paragraph style' from the selected text in my text frame and adding so extra stuff.

      So far it creates the 'paragraph style' but i have to manually selected the newly created style and redefine it, before it works.


      This is my code:


      var styleName = "Paragraph Style";

           var styles = app.activeDocument.paragraphStyles;

           var style;


           try {

                 style = styles.item(styleName);

                 var n = style.name;


           catch (myError) {

                 style = styles.add({

                       name: styleName,

                       alignToBaseline: false,

                       spaceBefore: 2,

                       spaceAfter: 2,