Set Paragraph Text
set_paragraph_textReplace a specific paragraph's text in a Word document, preserving its style and formatting. Use a location object to target the paragraph, with optional 'expect' check to avoid wrong edits.
Instructions
Replace one paragraph's full text, keeping style and base formatting; address it with a location object ({paragraph: N}, {search: ...}, {outline: ...}). Indices shift after edits, so pass expect (a substring the target must contain) to refuse instead of hitting the wrong paragraph; verify the returned replaced_text. Auto-backup in file mode (backup=False skips rotation); atomic validated save. Edits go live on open documents (serialized); tracked-revision paragraphs refuse live. For batches, use apply_edits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| live | No | auto: file or live; force: live; off: refuse | auto |
| backup | No | ||
| expect | No | ||
| location | Yes | ||
| new_text | Yes | ||
| file_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||