I am working with InDesign server CS3. In my script I'm having problems calling to the function createTOC().
This is my code:
var estiloTOC = app.documents.firstItem().tocStyles.itemByName("EstiloTOC1");
I try de same code in the InDesign CS3 desktop version and it works.
test this example Script. I'm write and testing this Script on ID Server CS4. works fine. I hope it help you.
// It must be opened a document. Also a document can be created.
var myDocument = app.documents.item(0);
//If the TOC Style "myToc" does not already exist, create it.
// Importent: Try and Catch
myTocStyle = myDocument.tocStyles.item("myToc");
myTocStyle = myDocument.tocStyles.add();
myTocStyle.name = "myToc";
createBookmarks = true;
includeBookDocuments = true;
label = "myLabel";
title = "myTitle";
// Enter more Properties
Thanks for your help Andreas!!
I've just found the solution to my problem.
When you are editing your InDesign template from InDesign Desktop, and close the document with a master spread as the active page, the next time that you open the document from InDesign Server (app.open(File("c:\Template.indt"))) the active page by default would be a master spread, so we'll have problems when we try to place the Table of Contents from our script in the IndDesign Server.
By the moment the solution consist in always leave open the first page of the template before save & close it.