Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
What is this page about?
This page describes how to find and replace text in Word documents with various matching options.
Use one of the Replace methods to find or replace a particular string within the current range. It returns the number of replacements made, so it is useful for searching strings without replace. An exception is thrown if a captured or replacement string contains one or more special characters: paragraph break, cell break, section break, field start, field separator, field end, inline picture, drawing object, footnote.
The following code example shows how to find some text and replace it:
Document doc = new Document("../../data/document.doc");
// Replaces all 'sad' and 'mad' occurrences with 'bad'.
doc.Range.Replace("document", "document replaced", false, true);
// Replaces all 'sad' and 'mad' occurrences with 'bad'.
doc.Range.Replace(new Regex("[s | m]ad"), "bad");
doc.Save("replacedDocument.doc");
See also:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.