Table of contents
How to update TOC
You can update TOC using the 2-nd parameter of the createTOC() which replaces the existing TOC.
main(); function main() { var doc = app.activeDocument; var tocStyle = doc.tocStyles[0]; doc.createTOC(tocStyle, true); }