#407·OfficeCLI

docx: `style=Heading1` on a new document still gives no real heading in Word, which breaks screen-reader navigation (follow-up to #350)

Author: jooyoungseoCreated Sep 18, 2026Updated Sep 21, 2026

Summary

In a document made by officecli create, --prop style=Heading1 still gives a paragraph that Word treats as plain body text. The styles part defines only Normal, so the pStyle points at nothing. #350 reported this. #355 fixed the batch part (the warning now shows in batch too), but the rest is unchanged in 1.0.151:

  • The built-in heading styles are never defined, either by create or when first used.
  • validate and view issues pass the file.
  • view outline shows the paragraph as a heading.

Why this matters (accessibility): Screen-reader users (JAWS, NVDA, and others) rely on headings to move around a Word document. A document built the way the SKILL.md Quick Start and the word skill's "Minimal viable docx" example show (create, then add ... --prop style=Heading1) has no headings for them at all. The Navigation pane and any TOC are empty too. The agent checks view outline, sees headings, and reports the document as done.

While working around it I found a second problem: defining the style yourself only works if its name is exactly the built-in heading N (details below).

Repro (officecli 1.0.151)

bash
officecli create a.docx
officecli add a.docx /body --type paragraph --prop "text=Introduction" --prop style=Heading1
#   WARNING: style 'Heading1' not found in styles part — will be referenced as-is
officecli view a.docx outline   # ├── [1] "Introduction" (Heading1)
officecli view a.docx issues    # nothing about the missing style
officecli validate a.docx       # Validation passed: no errors found.
officecli close a.docx

What Word actually sees

Checked in Word for Microsoft 365 (16.0.19530) through COM, reading Paragraph.Style.NameLocal and Paragraph.OutlineLevel (1–9 = heading level, 10 = body text):

Style setup before --prop style=HeadingN What officecli wrote to styles.xml Word style Outline level Real heading?
None (plain create) Nothing (only Normal is defined) Normal 10 No
add /styles --type style --prop id=Heading2 --prop type=paragraph --prop basedOn=Normal <w:style w:type="paragraph" w:styleId="Heading2"><w:basedOn w:val="Normal"/></w:style> (no w:name) (empty) 10 No
Same, with --prop name=Heading4 <w:name w:val="Heading4"/> Heading4 10 No
Same, with --prop "name=Heading 5" <w:name w:val="Heading 5"/> Heading 5 5 Yes
Same, with --prop "name=heading 3" <w:name w:val="heading 3"/> Heading 3 3 Yes

Word matches a style to its built-in heading by the name heading N (case-insensitive, with the space), not by the style ID. So:

  • help docx add style says name "Defaults to 'id' when omitted", but no w:name is written at all (row 2).
  • Even if it defaulted to the ID, Word doesn't recognize Heading4 as a heading name (row 3).

view outline shows all five rows as headings. (A custom style with --prop outlineLvl=0 does get outline level 1 in Word. The word skill mentions this for TOCs, but its examples don't use it.)

Suggested fix

  1. Define built-in styles when they're first used. When style= names a built-in style ID that isn't in the styles part (Heading1–Heading9, Title, Subtitle, …), insert Word's built-in definition, as Word does the first time you apply a built-in style. For headings that means w:name="heading N" and w:outlineLvl w:val="N-1", with basedOn/next = Normal. Seeding Heading1–Heading6 in the non---minimal create baseline would also work.
  2. Fix add --type style for built-in IDs. Write w:name when it's omitted, as the help says. When the ID is HeadingN, default the name to the built-in heading N.
  3. Flag the dangling reference. Report a pStyle/rStyle with no matching w:styleId in view issues (or validate), and don't show it as a heading in view outline. This is part 2 of #350's suggested fix.
  4. Fix the docs until item 1 ships. Have the SKILL.md Quick Start and the word skill's "Minimal viable docx" example define the heading styles first. Agents copy those examples as they are.

Workaround

bash
officecli add a.docx /styles --type style --prop id=Heading1 --prop "name=heading 1" --prop type=paragraph --prop basedOn=Normal --prop next=Normal

Environment

  • officecli 1.0.151 (officecli-win-x64.exe)
  • Windows 11 Enterprise 10.0.26200; Word for Microsoft 365 16.0.19530.20184