-
Notifications
You must be signed in to change notification settings - Fork 532
command remove
zmworm edited this page Mar 21, 2026
·
53 revisions
Remove an element from the document.
officecli remove <file> <path>
Removes the element at the specified DOM path from the document. The element and all its children are permanently deleted.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path |
path |
string | Yes | - | DOM path of the element to remove (see Path Reference) |
# Remove a paragraph
officecli remove report.docx /body/p[3]
# Remove a table
officecli remove report.docx /body/tbl[1]
# Remove a table row
officecli remove report.docx /body/tbl[1]/tr[2]
# Remove a run from a paragraph
officecli remove report.docx /body/p[1]/r[2]
# Remove a header
officecli remove report.docx /header[1]
# Remove a bookmark
officecli remove report.docx "/bookmark[MyMark]"
# Remove an Excel sheet (by navigating to it)
officecli remove data.xlsx /Sheet2
# Remove a named range
officecli remove data.xlsx /namedrange[1]
# Remove a data validation
officecli remove data.xlsx /Sheet1/validation[1]
# Remove a PowerPoint slide
officecli remove slides.pptx /slide[3]
# Remove a shape from a slide
officecli remove slides.pptx /slide[1]/shape[2]
# Remove a chart
officecli remove slides.pptx /slide[1]/chart[1]- Removing an element shifts subsequent indices. For example, after removing
/body/p[2], the former/body/p[3]becomes/body/p[2]. - When removing multiple elements, work from highest index to lowest to avoid index shifting issues, or use batch mode.
Based on OfficeCLI v1.0.11