3

I'm trying to target a table of contents object that is generated by inDesign's createTOC function. I am successfully generating the object, but I can not set any kind of identifier properties like tocTF.name = "myToc" When I examine it in the Data Browser it is being identified as an [object Story] but without any properties except for length. I was also able to find it as a textFrame in it's containing layer when I was trying to troubleshoot in the console.

Function in Use

tocTF = doc.createTOC(tocStyle, true, undefined, [margins[1]+"px",  margins[0]+"px"], true, tocFolder);

Data Browser

Data Browser Screen Shot

Console

doc.layers.item(tocFolderName).textFrames.length Result: 1 doc.layers.item(tocFolderName).textFrames.item(0).id Result: 447428 doc.layers.item(tocFolderName).textFrames.item(0).name Result:

Although it's returning an ID number, I cannot use this for my purposes.

Uncle Slug
  • 853
  • 1
  • 13
  • 26

1 Answers1

0

You access it via Story not TextFrame. TOC is a type of story.

for (var i = 0; i < app.activeDocument.stories.length; i++) {
    if (app.activeDocument.stories [i].storyType == StoryTypes.TOC_STORY) {
      //DO SOMETHING HERE
    }
}

You then can access the text box holding the story like so:

for (var i = 0; i < app.activeDocument.stories.length; i++) {
    if (app.activeDocument.stories [i].storyType == StoryTypes.TOC_STORY) {
        var toc_story = app.activeDocument.stories [i];
        var text_frame = toc_story.textContainers [0];
    }
}

More on that here.

Michael
  • 75
  • 9