3 Replies Latest reply on Nov 11, 2012 9:36 AM by multireflex

    Re-apply ObjectStyle

    multireflex Level 1

      Hi there, (en español abajo | en français en bas)

      Is there anybody that can help me with a JavaScript that would re-apply ObjectStyle to objects (or text frame).


      The problem: when I import an Xml into frame that have already an ObjectStyle that applies "ParragraphStyle and next" the «and next» option does not work [InDesignCS6]. The Xml text imported stays we the first ParragraphStyle found.


      To avoid re-applying manualy all ObjectStyles, I would like to make a JavaScript that re-applies the objectStyle;

      something like:

      loop from first to last object found in doc{


           reapply ObjectStyle "myOs" to object

           goto next object

           exit after last

      } end loop


      Do you think it is a good idea?

      Is there anybody that could help me with the JavaScripting




      Me gustaría obtener un JavaScrip para re-aplicar su estilo a un objeto.

      Al importar un Xml pierdo la opción de "aplicar etilo siguiente" de los estilos de párrafo.

      He pensado que con un JavaScript que reaplique el estilo encontrado al objeto me evitaría hacerlo manualmente.




      J'aimerais un JavaScript pour ré-appliquer son style à un objet.

      Quand j'importe un Xml l'option "style suivant" des style de parragraphe ne s'applique pas.

      Je pense qu'avec un JavaScript qui ré-applique le style trouvé à l'objet cela m'éviterais d'avoir a le faire a la main.


        • 1. Re: Re-apply ObjectStyle
          Jump_Over Level 5



          You could use this:


          var myDoc = app.activeDocument;

          var myTF = myDoc.textFrames.everyItem().getElements();

          for (var k = 0; k < myTF.length; k++)




          1st boolean parameter means to clear the TextFrame's existing attributes before applying the style;

          2nd boolean parameter means to clear attributes and formatting applied to the TextFrame that are not defined in the object style.


          hope it could help you, ciao

          • 2. Re: Re-apply ObjectStyle
            multireflex Level 1

            Thank you so much this is just perfect, exactly what I needed!


            • 3. Re: Re-apply ObjectStyle
              multireflex Level 1

              Hi JumpOver

              Thank you for your script!

              Now my second problem is that it does not work with enchored objects. I need to re-apply the style also to those object if not the next parragraph style does not apply after importing Xml.

              Is there aspecial JavaScript order for EnchoredObjects?


              Thank you for your time and help

              Best regards