2 Replies Latest reply on Jun 18, 2009 3:59 PM by Ben756

    remove textFrames from pages




      I'm new to the javascripting side of InDesign CS2 and am trying to put together a script that removes multiple textFrames based on its geometricBounds over a facing page doc with rulers set to spread.


      Here is a snippet I've been trying to work with


      var myDocument = app.activeDocument;
      var myCentreLots = myDocument.textFrames;

          if(myCentreLots[a].geometricBounds[0]==10,  90){


      this works in part but it seems to have a varied result removing random textboxes over the page...


      Is it possible to remove textFrames if not with geometricBounds then within an area of the page say within 20mm from the right edge of the even pages and 20mm of the left edge of the odd pages?


      See example.pdf... need to remove left over textFrames from within the green area as a result from a data merge.



        • 1. Re: remove textFrames from pages
          [Jongware] Most Valuable Participant

          You store a reference to all current text frames into your variable myCentreLots. However, as soon as you remove one single frame, that variable is not updated -- making its contents invalid. That's why it appears to remove random frames.


          Make the loop go the other way around; if you start at the end and remove a frame (or not), those 'before' it are unaffected:


          for(a=myCentreLots.length-1; a >= 0; a--)


          It's a common trick to work with references to ID objects.

          • 2. Re: remove textFrames from pages
            Ben756 Level 1

            Thanks [Jongware] that seemed to do the trick.... hadn't seen that reverse loop before..