Repository navigation
word sdt add
goworm edited this page Jul 7, 2026
·
53 revisions
Add structured document tags (content controls) for forms and structured content.
Type: sdt/contentcontrol
Parent: /body (block-level) or /body/p[N] (inline)
| Property | Default | Description |
|---|---|---|
sdtType/controltype
|
text |
Control type: text, richtext, dropdown, combobox, date, checkbox (<w14:checkbox>). group and picture are also add-time-supported control types but not covered by the examples below. buildingBlockGallery/repeatingSection are not implemented at add-time — create those in Word, then edit via CLI. Type cannot be changed after creation. |
alias/name
|
- | Display name |
tag |
- | Tag identifier |
lock |
unlocked |
Lock mode: unlocked, contentlocked, sdtlocked, sdtcontentlocked
|
text |
- | Default text content |
items |
- | Comma-separated items (for dropdown/combobox) |
format |
yyyy-MM-dd |
Date format (for date type) |
placeholderText |
- | docPart gallery reference for the placeholder content (<w:placeholder><w:docPart w:val=.../></w:placeholder>) |
date.fullDate |
- | Date-picker selected value as ISO-8601 UTC (w:fullDate). The actual chosen date, distinct from the display format |
date.calendar |
- | Date-picker calendar system (w:calendar), e.g. gregorian, hijri, japan
|
date.lid |
- | Date-picker locale/language id (w:lid), e.g. en-US
|
date.storeMappedDataAs |
- | Date-picker XML-mapping storage type (w:storeMappedDataAs), e.g. dateTime, date, text
|
comboBox.lastValue |
- | Combobox current selection (w:lastValue on <w:comboBox>) |
dropDown.lastValue |
- | Dropdown current selection (w:lastValue on <w:dropDownList>) |
checked |
false |
Checkbox content-control checked state (<w14:checked w14:val="1|0">). Checkbox controls only. The content run shows ☒ (checked) / ☐ (unchecked). Not namespaced under checkbox. — the key is bare checked. There is no separate custom-glyph property; the ☒/☐ glyphs are fixed. |
# Add a plain text content control
officecli add report.docx /body --type sdt --prop sdtType=text --prop alias="Name" --prop tag="name" --prop text="Enter name"
# Add a dropdown content control
officecli add report.docx /body --type contentcontrol --prop controltype=dropdown --prop alias="Status" --prop items="Draft,Review,Final"
# Add a date picker content control
officecli add report.docx /body --type sdt --prop sdtType=date --prop alias="Due Date" --prop format="MM/dd/yyyy"
# Add a locked content control (content cannot be edited)
officecli add report.docx /body --type sdt --prop sdtType=richtext --prop lock=contentlocked --prop text="Protected content"
# Add an inline content control within a paragraph
officecli add report.docx /body/p[1] --type sdt --prop sdtType=text --prop alias="Inline Field" --prop text="fill in"
# Add a combobox (editable dropdown)
officecli add report.docx /body --type sdt --prop sdtType=combobox --prop alias="Department" --prop items="Sales,Engineering,Marketing,Other"
# Add a checked checkbox control (bare 'checked' key, not 'checkbox.checked')
officecli add report.docx /body --type sdt --prop sdtType=checkbox --prop alias="Agree" --prop checked=trueBased on OfficeCLI v1.0.127