2 Replies Latest reply on May 4, 2012 7:32 AM by PrntScr

    [JS][CS5] finding instances of a Paragraph style, and doing something to the parentTextFrame

    PrntScr Level 1



      From being helped earlier with looping through objects looking for a fill color, and then deleting found objects, I decided to try and reuse the loop for another purpose.



      I'd like to loop through all stories in a document, finding those who have a particular paragraph style applied to them, and then 'climb out' using .parentTextFrame[0] to move the containing text frame.


      Here's what I have:




      function Main() {

          var doc = app.activeDocument;

          var stories = doc.stories;

          var STYLE = doc.paragraphStyles.item("STYLE");

          for (var i = stories.length-1; i >= 0; i--) {

              if (stories[i].appliedParagraphStyle == STYLE) stories[i].parentTextFrames[0].move([3,5]);





      The script executes but the frames don't move.


      "if (stories[i].appliedParagraphStyle == STYLE) stories[i].parentTextFrames[0].move([3,5]);"
      "if (stories[i].appliedParagraphStyle == STYLE) stories[i].remove();"  
      deletes the story.


      I'm thankful for any help. Looks like this should work in theory, but obviously there is something wrong..