7 Replies Latest reply on Jun 3, 2008 4:47 AM by (Dave_Saunders)

    Anchored frame selection

      Is the textframe is different from Anchored textframe. I couldn't able to select the anchored textframe by the below code.

      mydoc.Pages(i).TextFrames(j).Select()

      It only selects the non-anchored textframes.
        • 1. Re: Anchored frame selection
          An anchored textframe is a child of another textframe. So it would be something like mydoc.Pages(i).TextFrames(j).TextFrames(k).Select().

          Or better, if all frames are anchored within one story, use that story's TextFrames collection.
          • 2. Re: Anchored frame selection
            Level 1
            Hi,

            I am new to indesign scripting. Post sample code for Stories textframe collection. It would be helpful.
            • 3. Re: Anchored frame selection
              Level 1
              Are you using CS2 or CS3. The answer to your question is different according to the version you're using because of a change in the object model with CS3.

              Use the Object Model Viewer (OMV) in ESTK 2's Help menu to explore the CS3 object model.

              Dave
              • 4. Re: Anchored frame selection
                Level 1
                I am using CS2 with vb.net.

                I want to select all the anchored textframes named "RemAnchor" in a .indd file then copy the contents with page number in a text file.
                • 5. Re: Anchored frame selection
                  Level 1
                  Dave,

                  This does work for textframes but it's not working for anchored frames.

                  For h = 1 To mydoc.Pages.Count
                  For j = 1 To mydoc.Pages(h).TextFrames.Count
                  mydoc.Pages(h).TextFrames(j).Select()
                  For k = 1 To mydoc.Pages(h).TextFrames(j).Paragraphs.Count
                  mydoc.Pages(h).TextFrames(j).Paragraphs(k).Select()
                  Next
                  Next
                  Next
                  • 6. Re: Anchored frame selection
                    Level 1
                    There is more than one way you can tackle this. You could start with the stories and check to see if the first frame of each story has the appropriate label and which has a parent of character (which tells you that it is anchored).

                    Or, you could again start with the stories and use (JavaScript):

                    myStory.texts[0].textFrames.item("RemAnchor").getElements();

                    to get an array of the anchored text frames in the story.

                    In either of these approaches, you'll then need to seek out the page by looking up the parental chain.

                    If you want to start with the pages, then, as you've discovered, the textFrames property of a page gives you only the frames that are free-standing on the page, so you don't get the anchored ones. What you could do is use the page's allPageItems property -- that'll give you all the page items on the page including the anchored one. You could then check each to see (a) if it is a text frame, (b) if it has the right label, and (c) if is in indeed anchored (as above).

                    Dave
                    • 7. Re: Anchored frame selection
                      Level 1
                      By the way, I said that CS2 and CS3 are different, but actually:

                      myStory.texts[0].textFrames;

                      will get all the anchored text frames of myStory in both CS2 and CS3. It's just that in CS3:

                      myStory.textFrames;

                      gives you the anchored frames in myStory while in CS2 it gives you the frames that make up the story.

                      Dave