replace_formatted
Replace text only where specific formatting (bold, italic, font, color, style) matches, preserving that formatting. Safe across fragmented runs; aborts if limit exceeded.
Instructions
Replace text ONLY where it carries specific EFFECTIVE formatting: the mutation twin of find_formatted, same criteria keys (bold/italic/underline/strike, font, size_pt, color, highlight, style), all required together, resolved the way Word resolves them. find=None replaces each entire matching stretch; with find (literal, case-sensitive), only occurrences wholly inside a matching stretch. Safe across fragmented runs; the replacement keeps the matched formatting. Result mirrors search_and_replace ({replaced, total}) plus per-replacement matched_via. No regex here (search_and_replace covers that); text boxes are never touched (set_textbox_text edits those). max_replacements aborts, changing nothing, past the cap. Auto-backup: prev/anchor slots in .ks4w-backups (backup=False skips rotation only); atomic validated save. Refuses documents open in Word.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | No | ||
| scope | No | body | |
| backup | No | ||
| replace | Yes | ||
| file_path | Yes | ||
| formatting | Yes | ||
| max_replacements | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||