docx: `style=Heading1` on a new document still gives no real heading in Word, which breaks screen-reader navigation (follow-up to #350)
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
createor when first used. validateandview issuespass the file.view outlineshows 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)
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.docxWhat 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 stylesaysname"Defaults to 'id' when omitted", but now:nameis written at all (row 2).- Even if it defaulted to the ID, Word doesn't recognize
Heading4as 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
- 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 meansw:name="heading N"andw:outlineLvl w:val="N-1", withbasedOn/next=Normal. SeedingHeading1–Heading6in the non---minimalcreatebaseline would also work. - Fix
add --type stylefor built-in IDs. Writew:namewhen it's omitted, as the help says. When the ID isHeadingN, default the name to the built-inheading N. - Flag the dangling reference. Report a
pStyle/rStylewith no matchingw:styleIdinview issues(orvalidate), and don't show it as a heading inview outline. This is part 2 of #350's suggested fix. - Fix the docs until item 1 ships. Have the
SKILL.mdQuick Start and thewordskill's "Minimal viable docx" example define the heading styles first. Agents copy those examples as they are.
Workaround
officecli add a.docx /styles --type style --prop id=Heading1 --prop "name=heading 1" --prop type=paragraph --prop basedOn=Normal --prop next=NormalEnvironment
- officecli 1.0.151 (
officecli-win-x64.exe) - Windows 11 Enterprise 10.0.26200; Word for Microsoft 365 16.0.19530.20184
Source: iOfficeAI/OfficeCLI