4 Replies Latest reply on Oct 7, 2008 7:07 AM by try67

    Duplicating text frames for "autoflow" of text

    Level 1
      In a script I'm using the Duplicate command to duplicate a frame onto the next page (and all other subsequent pages) that already has a story flowed into it. I need to duplicate the frame to ensure I have all the same frame settings as the initial frame into which the story was flowed.

      Everything works fine except when I introduce the PreviousTextFrame command on the new frame to continue the text flowing instead of duplicating the same text. Then, the script boggs down to a crawl and eventually stalls completely.

      I'm thinking this may be because the new frame (to which I'm then setting the PreviousTextFrame property to flow the text along) already has text in it, but I've not found a way to simply remove existing text from a frame.

      Any ideas why things would be locking up and/or is there a way to simply remove a story from a text frame?

      Thanks,
      Ken
        • 1. Re: Duplicating text frames for "autoflow" of text
          Level 1
          Ken,

          You need to do more than empty the frame; you need to empty its parent story. This is particularly true if the frame you're duplicating is the last in the present story because in that case not only does the text in the frame get duplicated but also all the overset text.

          So, after duplicating the frame, you need either:

          myDupeFrame.parentStory.contents = "";

          or:

          myDupeFrame.parentStory.texts[0].remove();

          as the mood takes you. Then thread the empty frame to the end of the original story.

          Dave
          • 2. Re: Duplicating text frames for "autoflow" of text
            Level 1
            Works great now. Thanks, yet again.

            Only if you've got a moment, one thing I'm curious about is the .Remove command. I'm working in VB and it generates an error. I tried simplifying things just to check the command and selected a text fame with text in it and tried simply

            Ind.Selection(1).ParentStory.Texts(0).Remove

            With a zero in the "Texts" parameter I got "requested member of the collection does not exist." I THINK that is a difference between JS and VB, JS uses zero as the first element, VB uses 1. Using a 1 though causes a "Object doesn't support this propery or method" error.

            Any idea why?

            Thanks again,
            Ken
            • 3. Re: Duplicating text frames for "autoflow" of text
              Level 1
              Ah, that's a good point. Perhaps it's not such a great idea to use remove after all. When the contents of a text frame is just an insertionPoint then the texts[0] (in JavaScript) object is empty and can't be removed.

              On the other hand, if that does happen, you shouldn't be adding a frame at that point anyway. If you test for story overflow before duplicating the frame, you should never get to the point where you added an empty frame, should you?

              I realized after I'd posted that you were talking VB while I was answering in JS.

              Dave
              • 4. Re: Duplicating text frames for "autoflow" of text
                try67 MVP & Adobe Community Professional
                VB collections are 1-based, while JS collections are 0-based.
                Therefore, there's no such this as Texts(0) in VB. You need to change it to Texts(1).