14 Replies Latest reply on Oct 6, 2009 2:59 AM by Jeremy bowmangraphics-DQuh1B

    CS3/4, JS Amateur question: how remove all empty text frames?

    Jeremy bowmangraphics-DQuh1B Level 3

      I'm an amateur, and thought it would be a straightforward matter to write a script that simply deletes all empty text frames in all of a document's stories. Here's my second attempt:


      var myDocument = app.activeDocument;

      var myStories = myDocument.stories;

      for (i = 0; i < myStories.length; i++){

        var myStory = myStories[i];

        var myTextFrames = myStory.textContainers;

          for (j = myTextFrames.length - 1; j >=0; j--) {

          if (myTextFrames[j].contents == "") myTextFrames[j].remove();




      The trouble is, sometimes it works as intended, but sometimes, with multiple stories, it needs to be run more than once. Can anyone explain why that is?


      Thanks -- Jeremy