Skip to main content
Known Participant
September 27, 2009
Question

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

  • September 27, 2009
  • 5 replies
  • 2104 views

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.

This topic has been closed for replies.

5 replies

BrianMcMAuthor
Known Participant
October 2, 2009

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

Robert at ID-Tasker
Legend
October 2, 2009

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

BrianMcMAuthor
Known Participant
October 6, 2009

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

BrianMcMAuthor
Known Participant
September 30, 2009

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

Robert at ID-Tasker
Legend
September 30, 2009

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

Robert at ID-Tasker
Legend
September 30, 2009

hi

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

robin

www.adobescripts.co.uk

Harbs.
Legend
September 28, 2009

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

Harbs.
Legend
September 28, 2009

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

Harbs.
Legend
September 28, 2009

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];