Skip to content

word toc

goworm edited this page Jul 17, 2026 · 52 revisions

Word: Table of Contents

Auto-generated table of contents based on heading levels.

Path: /toc[N]

Operations

  • add - Add a table of contents

set

officecli set report.docx /toc[1] --prop levels=1-4 --prop hyperlinks=true

Word-side pitfall: real heading sources required

add --type toc never fails, even over paragraphs with no real heading — officecli doesn't validate this because populating a TOC needs a pagination engine Word alone has. But when Word itself opens the file and recalculates fields, a TOC built over paragraphs that are merely bold/large Normal text (not an actual Heading1Heading9 style, or a custom style with outlineLvl set) renders "Error! No table of contents entries found." — verify the target paragraphs carry a real heading style (or outlineLvl) before adding a TOC over them, and set updateFields=true on / or /settings so Word recomputes the entries on open instead of showing a stale/empty write-time cache. There's no hand-written static-TOC fallback for page numbers — officecli can't compute pagination, so any static number would be a guess; defer to Word via updateFields or run refresh for what it can compute (SEQ, not page numbers).


Based on OfficeCLI v1.0.137

Clone this wiki locally