insert_toc
Insert a Table of Contents into a Word document with configurable heading depth and automatic page number updates on open or field refresh.
Instructions
Insert a Table of Contents (SDT-wrapped TOC field); levels like '1-3' picks heading depth. Page numbers appear after Word updates fields: automatically on next open (update_on_open) or immediately via com_refresh_fields. Auto-backup: prev/anchor slots in .ks4w-backups (backup=False skips rotation only); atomic validated save. Refuses documents open in Word.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Table of Contents | |
| backup | No | ||
| levels | No | 1-3 | |
| at_start | No | ||
| file_path | Yes | ||
| after_index | No | ||
| update_on_open | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||