add_heading
Insert a new heading (levels 1-9) at a chosen position in a Word document, creating missing heading styles automatically. Supports positioning by index, anchor text, or end; includes backup and validation.
Instructions
Insert a NEW heading paragraph (level 1-9; Heading styles auto-created if missing) positioned by after_index, after_anchor, or at_end. Anchors match plain paragraph text, and heading text recurs in body prose, so prefer after_index for structural work. To restyle an EXISTING paragraph use apply_style; to shift existing heading levels use change_heading_level. 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 |
|---|---|---|---|
| text | Yes | ||
| level | No | ||
| at_end | No | ||
| backup | No | ||
| file_path | Yes | ||
| after_index | No | ||
| after_anchor | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||