1 person found this helpful
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.
Excellent nice catch