Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

command refresh

zmworm edited this page May 5, 2026 · 1 revision

refresh

Recalculate derived field values — TOC page numbers, PAGE / NUMPAGES, cross-references — and write them back to the document.

Synopsis

officecli refresh <file> [--json]

Description

.docx only. Two backends:

Backend When Notes
word Windows + Word installed Calls Word COM Fields.Update. Layout-accurate.
html All other platforms (and as fallback) Regenerates TOC bodies via the internal WordTocBuilder (4-phase pipeline mirroring LibreOffice), paginates via headless Chrome --dump-dom, then writes back PAGEREF result runs and app.xml <Pages>. TOC page numbers reflect officecli's HTML pagination and may differ from Word's layout.

The selected backend is reported on stdout (backend: word|html); the HTML fallback also prints a stderr disclaimer.

If the Word backend is unavailable and no headless browser is found, the command fails with exit code refresh_failed.

Examples

# Refresh TOC + PAGE fields in place
officecli refresh report.docx
# JSON envelope
officecli refresh report.docx --json

See Also

  • word-toc — TOC element reference
  • word-field — PAGE / NUMPAGES / PAGEREF / SEQ
  • command-viewview stats --page-count for total page count without writing back

Based on OfficeCLI v1.0.73

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /