2 Replies Latest reply on Jun 5, 2010 7:00 AM by Maria964

    Script for selecting consecutive paragraphs -- can anyone help me?

    Maria964 Level 1



      I have this script that works fine. It aplies Style Then Next Style to the paragraphs that I have selected with the keyboard in Indesign CS5:


      var style_name = "cabecalho"

      var doc = app.documents[0];

      var first_pstyle = doc.paragraphStyles.item(style_name);

      var cur_sel = app.selection[0].paragraphs;

      cur_sel[0].appliedParagraphStyle = first_pstyle;

      if (cur_sel.length > 1) 


           for (n = 1; n < cur_sel.length; n++)


                cur_sel[n].appliedParagraphStyle = cur_sel[n-1].appliedParagraphStyle.nextStyle;




      But before running it I have to use the keyboard to select the 3 paragraphs for the script. I know that it is possible to add some code in the beginning to make the script select the paragraph where the cursor is and the next 2 paragraphs and avoid the manual selection because it is always 3 paragraphs.

      I do not know how to do this. Can anyone help me?


      Thank you in advance. Greetings from Madrid