2 Replies Latest reply on Apr 15, 2011 1:03 AM by John Hawkinson

    Add some text at occurrence of a given style


      Hi All!


      We are new to Indesign scripting and look for some help.


      We have a book broken into many sections. What we want to do is add a particular ornament character whenever the section ends.


      Each section starts with a particular style. So if we can add this ornament text just before this style's occurrence it would work.


      How can we do this? All help/pointers really appreciated.




        • 1. Re: Add some text at occurrence of a given style
          csm_phil Level 4

          Hi g,


          If you dont mine can you exlain clearly and give some example screen shot its better to automate what you expect that?




          • 2. Re: Add some text at occurrence of a given style
            John Hawkinson Level 5
                d = app.activeDocument,
                s = d.stories,
                i,j, p;
            // Repeat for all stories.
            for (i=0; i<s.length; i++) {
                p = s[i].paragraphs;
                // Repeat for all paragraphs in the story
                for (j=0; j<p.length; j++) {
                    // If the paragraph begins the section.
                    if ((p[j].appliedParagraphStyle.name ===
                            "MY SECTION START") &&
                        // AND if the pargraph is either the
                        // first graf of the section, or if
                        // the style is different from the previous
                        // style
                        ((j===0) || p[j].appliedParagraphStyle !==
                        // Then we insert the ornament
                        p[j].insertionPoints[0].contents =