-
Notifications
You must be signed in to change notification settings - Fork 541
command query word
zmworm edited this page Mar 21, 2026
·
51 revisions
Query selectors for Word documents.
| 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) |
| 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 |
| Operator | Meaning | Example |
|---|---|---|
= |
Exact match | [style=Heading1] |
!= |
Not equal | [font!=Arial] |
~= |
Contains text | [text~=quarterly] |
>= |
Greater or equal (numeric) | [size>=24pt] |
<= |
Less or equal (numeric) | [size<=12pt] |
Notes:
- Can combine:
paragraph[style=Heading1][size>=14pt] - Color-aware:
[fill=#FF0000]matches[fill=FF0000] - Dimension-aware: compares
2cmvs1incorrectly - Special keys
textandtypematch node content and type -
\!=accepted for zsh compatibility
| Attribute | Description |
|---|---|
fieldType |
Field type (e.g. page, numpages, date). Supports != filter (e.g. field[fieldType!=page]). Use \!= for zsh compatibility. |
| Attribute | Description |
|---|---|
font |
Font name |
size |
Font size |
bold |
Boolean |
italic |
Boolean |
| 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 |
# 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")'
# Paragraphs with font size >= 14pt
officecli query report.docx "paragraph[size>=14pt]"
# Runs with color containing "dark"
officecli query report.docx "run[color~=dark]"- query - Command syntax
- Word Reference - All Word elements
Based on OfficeCLI v1.0.11