Insert TOC into specific text frame
Hi,
I'm trying to insert a TOC and then later update it on a specific page of my catalogue document. The document is being created programmatically using scripts. CreateTOC is a document level method and works well as in:
var myDocument = app.documents.firstItem();
var myTOC = myDocument.tocStyles.itemByName("DirectoryTOC");
myDocument.createTOC(myTOC);
That puts a TOC on the current page at position 0,0 in a new text frame. However I want the TOC to go specifically into the text frame already placed on page 4 of my document.
Because I am also paginating data into the document programmatically, I need to do the following:
- Insert TOC page and add a TOC to it
- Insert data into catalogue pages
- Update TOC (this should insert extra pages at front of document to the TOC section depending on how much data was added to catalogue pages)
- Update TOC again, because the page numbers for the catalogue data will now have shifted by the number of pages added into the TOC.
- Then continue to add content at the end of the document.
So does anyone know how I can target a specific text frame for my new TOC, and then once done, what would I use to update said TOC later on?
I tried also using the ID of the menu command to insert a TOC, but all that does is pop open the Create Toc dialog. Not helpful to me because the document is being created by scripts.
Cheers,
Rob
