11 Replies Latest reply on Oct 6, 2009 5:29 PM by BrianMcM

    Can you change a story or text frame's index? (re autonumbering)

    BrianMcM

      Does anyone know if there is a way to change the index of a text frame or story without changing the actual visual layout of an InDesign document? So far all I can come up with is to cut the frame and repaste it into the document. You can move a story within the index list of a document, but that visually cuts and pastes the story text.

       

      actDoc.stories.item(1).move(LocationOptions.BEFORE, actDoc.stories.item(0));

       

      I can't see any method to change the index of a text frame (other than cutting and repasting).

       

      I want to put together some tests. I have a bunch of questions. Each question is a single story in a single text frame in an InDesign document. The text frame is linked to an InCopy document. The first paragraph of the question has a "QuestionNumber" style but the para style has no numbering. I want to have only one version of each question (the InCopy story) but to put the questions into different tests in different orders with different numbering. What I do is to create an InDesign template for the tests that has a QuestionNumber para style that includes autonumbering with the "Continue Numbers across Stories" option checked. This works beautifully and the questions are numbered in the order in which the text frames (and stories) are (via a script) copied from the question document and pasted into the test paper document. When the same question/story/textframe is used in two tests it is numbered in the order in which it is pasted into each test paper (but the original stays the same because it has no numbering).

       

      The next step would be to be able to reorder the question numbers within the test paper (if you wanted to, say, swap questions 18 and 20). To do that you have to change the index of the story because the autonumbering across stories seems to depend on the index of the story.

       

      What seems to happen is that stories are indexed in the order in which they are pasted into a document, but text frames are indexed in the opposite order. If you paste a text frame with one story into a new document, it is textframe.item(0) and story.item(0). If you then paste a second one into the document it is story.item(1) but textframe.item(0). The first text frame becomes textframe.item(1). When you cut a text frame and repaste it, it is reindexed as if you were pasting it for the first time.

       

      The autonumbering also seems to be segregated by page. If you have questions 1 and 2 on page 1 and questions 3 and 4 on page 2, you can move around the text frames for 1 and 2 on the page but the numbering stays the same. Likewise for 3 and 4. If you drag 3 across to page 1 it stays as 3 but if you drag question 4 across to page 1 it becomes 3, and the original question 3 on page 2 becomes question 4. It is confusing but makes sense in a weird way once you get the hang of it.

       

      Anyway, I have probably answered my own question and the best way to renumber the questions in a test is to run the script again and create a new document using a new question order.

       

      But any other ideas are welcome.

       

      Thanks.

        • 1. Re: Can you change a story or text frame's index? (re autonumbering)
          Harbs. Level 6

          I didn't read your whole question. (My eyes start crossing when a 

          question is too wordy...)

           

          If I understood you correctly, you want to connect two stories.

           

          The way that's done is to set the nextTextFrame of the last text frame 

          of the first story as the first text frame of the second one:

           

          In CS3 or later:

           

          story1.textContainers[-1].nextTextFrame = story2.textContainers[0];

           

          Harbs

          • 2. Re: Can you change a story or text frame's index? (re autonumbering)
            Harbs. Level 6

            Sorry. It slipped my mind that textContainers is an array -- not a collection. That should have been:

             

            story1.textContainers[story1.textContainers.length-1].nextTextFrame = story2.textContainers[0];
            • 3. Re: Can you change a story or text frame's index? (re autonumbering)
              Harbs. Level 6

              I just re-read (read?) your question.

               

              Okay, threading the stories (like I suggested) might work, but you'll probably want to insert frame breaks at the end of each text frame to keep the text content.

               

              If you don't want to keep the threading, you can break the threading (which will in-effect create a new story), and put the text back in the original text frame. It will then be the last story on the page.

               

              HTH

              Harbs

              • 4. Re: Can you change a story or text frame's index? (re autonumbering)
                AdobeScripts Level 3

                hi

                 

                can you shuffle your questions in script and place in new order each time ?

                 

                robin

                 

                www.adobescripts.co.uk

                • 5. Re: Can you change a story or text frame's index? (re autonumbering)
                  BrianMcM Level 1

                  Thank you Harbs and Robert for replying to my post. It is a bit too long, isn't it?

                   

                  I don't think that I will merge and separate the stories in order to try to change the autonumbering. It does make the most sense just to regenerate the document (the test paper) using a different list of questions.

                   

                  I forgot to mention in the original post that not only is each question a story within a text frame in an InDesign doc linked to an InCopy doc, but the question text frame and story are also tagged with an XML element which has attributes for various metadata like the correct answer, the subject of the question, how hard it is and so on. So I want to keep all of the questions discreet so that the XML markup stays intact and the version control stays intact, with the only version being the one in the InCopy story that is linked to all the various InDesign files.

                   

                  The questions are all short enough to fit into one text frame, so my idea is to just copy and paste the text frames onto the pages of a template test paper document. The script (which I haven't written yet) will place the text frames on the page one by one so that it looks like the copy is one story flowing through linked text frames from page to page, but really there will be a separate text frame for each question.

                   

                  It sounds good in theory. As I said, the goal is to have only one version of each question that is linked into any number of InDesign docs. Due to the way InCopy works with linked stories (you can't have two linked stories within one text frame), I have to keep each story separated within its own text frame.

                   

                  Brian

                  • 6. Re: Can you change a story or text frame's index? (re autonumbering)
                    AdobeScripts Level 3

                    hi Brian,

                     

                    I don't see any problem at all if you work on PC - you can contact me on priv and I can make script for you

                     

                    and instead of many separate TextFrames - you can placed them as InLine or AnchoredObjects

                     

                    robin

                     

                    www.adobescripts.co.uk

                    1 person found this helpful
                    • 7. Re: Can you change a story or text frame's index? (re autonumbering)
                      BrianMcM Level 1

                      Thank you, Robin.

                       

                      I have had a quick look at your website. I want to read through the descriptions and see what your scripts do.

                       

                      I hope to write my script myself. I need the practice.

                       

                      I have tried to use inline text frames but I believe that if the text frame is linked to InCopy, you lose the link when you place it inline.

                       

                      Brian

                      • 8. Re: Can you change a story or text frame's index? (re autonumbering)
                        AdobeScripts Level 3

                        BrianMcM wrote:

                         

                        I have tried to use inline text frames but I believe that if the text frame is linked to InCopy, you lose the link when you place it inline.

                         

                        I don't have InCopy so I can't check it - but I've checked DOC file and I can place it as linked in Anchored TF

                         

                        robin

                         

                        www.adobescripts.co.uk

                        • 9. Re: Can you change a story or text frame's index? (re autonumbering)
                          BrianMcM Level 1

                          Hi, Robin.

                           

                          If I have a text frame that is linked to an InCopy document and copy and paste that frame inline into another text frame, the new pasted text frame is no longer linked to the InCopy document. (If I paste the text frame onto the page, the link remains.)

                           

                          I have written my script using individual text frames and it seems to work fine.

                           

                          Thanks.

                           

                          Brian

                          • 10. Re: Can you change a story or text frame's index? (re autonumbering)
                            AdobeScripts Level 3

                            hi Brian

                             

                            which version of InDesign you have ?

                            I have checked these steps on CS3 and CS4:

                             

                            first I've set ON to option in preferences to preserve links when placing

                            then I've placed DOC file as AnchoredTF in new Story

                            then I've copied this AnchoredTF and pasted it on page, and then I've pasted it as another AnchoredTF - each time there was new lick created to the same DOC file

                            then I've set OFF to option in preferences to preserve links when placing

                            and even when I again copied and pasted this AnchoredTF with placed DOC file - it still add new link on Links palette

                             

                            so maybe with InCopy stories there is next bug or next "feature" ...

                             

                            [edit]

                            ok - I've checked InCopy file - after exporting TextFrame as InCopy Story

                            and it's like you've said - pasting on page - new link is created - pasting as Anchored - link isn't created ... no matter if option in preferences is set or not ...

                             

                            verdict - we've found new bug

                             

                            BUT ... if you link it again - by CTRL+D method - link is preserved even if option in preferences is set to off so you can have more than one InCopy Story placed as AnchoredTF in same parent Story ...

                             

                            robin

                             

                            www.adobescripts.co.uk

                            • 11. Re: Can you change a story or text frame's index? (re autonumbering)
                              BrianMcM Level 1

                              Hi, Robin.

                               

                              I am using InDesign CS4 on a PC.

                               

                              You are definitely right about placing the InCopy files. You can place InCopy files into  inline text frames inside of a container text frame and they are linked. Awesome.

                               

                              That will give me a new way to look at the whole problem.

                               

                              Thanks a lot for your help.

                               

                              Brian