ReplaceText()

Presentation::ReplaceText(System::String, System::String, System::SharedPtr<ITextSearchOptions>, System::SharedPtr<IFindResultCallback>) method

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

void Aspose::Slides::Presentation::ReplaceText(System::String oldText, System::String newText, System::SharedPtr<ITextSearchOptions> options, System::SharedPtr<IFindResultCallback> callback) override

Arguments

ParameterTypeDescription
oldTextSystem::StringThe string to be replaced.
newTextSystem::StringThe string to replace all occurrences of oldText.
optionsSystem::SharedPtr<ITextSearchOptions>Text search options ITextSearchOptions.
callbackSystem::SharedPtr<IFindResultCallback>The callback object for receiving search results IFindResultCallback.

Remarks

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

auto presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");

auto textSearchOptions = System::MakeObject<TextSearchOptions>();
textSearchOptions->set_WholeWordsOnly(true);

// Replace all separate 'the' occurrences with '<em><strong>'
presentation->ReplaceText(u"the", u"</strong></em>", textSearchOptions, nullptr);
presentation->Save(u"SomePresentation-out2.pptx", SaveFormat::Pptx);

See Also