ReplaceText

ITextFrame.ReplaceText method

Replaces all occurrences of the specified text with another specified text.

public void ReplaceText(string oldText, string newText, ITextSearchOptions options, 
    IFindResultCallback callback)
ParameterTypeDescription
oldTextStringThe string to be replaced.
newTextStringThe string to replace all occurrences of oldText.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

Examples

The following sample code shows how to replace one specified string with another specified string.

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// Replace all separate 'the' occurrences with '***'
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.ReplaceText("the", "***", new TextSearchOptions()
	{ WholeWordsOnly = true }, null);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

See Also