Skip to content

command query word

zmworm edited this page Mar 20, 2026 · 51 revisions

query - Word (.docx)

Query selectors for Word documents.

Element Selectors

Selector Aliases Description
paragraph p Paragraphs
run r Text runs (child selector only, use with >)
table tbl Tables
picture image, img Inline images
equation math, formula Equations
bookmark - Bookmarks
header - Headers
footer - Footers
chart - Charts
comment - Comments
field - Document fields
sdt contentcontrol Structured Document Tags (content controls)

Paragraph Attributes

Attribute Description
style Style name or ID (case-insensitive)
alignment left, center, right, justify
firstLineIndent Indent value
numId Numbering ID
numLevel / ilvl Numbering level
listStyle List style

Field Attributes

Attribute Description
fieldType Field type (e.g. page, numpages, date). Supports != filter (e.g. field[fieldType!=page]). Use \!= for zsh compatibility.

Run Attributes (child selector with >)

Attribute Description
font Font name
size Font size
bold Boolean
italic Boolean

Pseudo-Selectors

Selector Applies To Description
:contains("text") paragraphs, runs Contains text
:empty paragraphs No content
:no-alt pictures Missing alt text
:text shorthand Shorthand selector syntax

Examples

# All Heading 1 paragraphs
officecli query report.docx "p[style=Heading1]"

# Bold runs in centered paragraphs
officecli query report.docx "p[alignment=center] > r[bold=true]"

# Runs containing specific text
officecli query report.docx 'r:contains("error")'

# Empty paragraphs
officecli query report.docx "p:empty"

# Images without alt text
officecli query report.docx "image:no-alt"

# Paragraphs NOT in Normal style
officecli query report.docx "p[style!=Normal]"

# All bookmarks
officecli query report.docx "bookmark"

# All equations
officecli query report.docx "equation"

# All fields
officecli query report.docx "field"

# Only page number fields
officecli query report.docx "field[fieldType=page]"

# Fields that are NOT page fields
officecli query report.docx "field[fieldType!=page]"

# All content controls
officecli query report.docx "sdt"

# Fields containing specific instruction text
officecli query report.docx 'field:contains("DATE")'

See Also


Based on OfficeCli v1.0.9

Clone this wiki locally