Skip to content

command swap

zmworm edited this page Apr 4, 2026 · 27 revisions

swap

Swap two elements' positions.

Synopsis

officecli swap <file> <path1> <path2>

Description

Swaps the positions of two elements. Both elements must have the same parent (e.g., two paragraphs in the same body, two rows in the same table, two slides in the same presentation).

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path
path1 string Yes - DOM path of the first element
path2 string Yes - DOM path of the second element

Examples

Word

# Swap two paragraphs
officecli swap report.docx /body/p[1] /body/p[3]

# Swap two table rows
officecli swap report.docx /body/tbl[1]/tr[1] /body/tbl[1]/tr[3]

Excel

# Swap two rows on the same sheet
officecli swap data.xlsx /Sheet1/row[1] /Sheet1/row[3]

PowerPoint

# Swap two slides
officecli swap slides.pptx /slide[1] /slide[3]

# Swap two shapes on the same slide
officecli swap slides.pptx /slide[1]/shape[1] /slide[1]/shape[2]

Notes

  • Both elements must share the same parent container.
  • After swapping, the indices of the elements change accordingly.

See Also


Based on OfficeCLI v1.0.33

Clone this wiki locally