ReplaceText()
Contents
[
Hide
]TextFrame::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::TextFrame::ReplaceText(System::String oldText, System::String newText, System::SharedPtr<ITextSearchOptions> options, System::SharedPtr<IFindResultCallback> callback) override
Arguments
Parameter | Type | Description |
---|---|---|
oldText | System::String | The string to be replaced. |
newText | System::String | The string to replace all occurrences of oldText. |
options | System::SharedPtr<ITextSearchOptions> | Text search options ITextSearchOptions. |
callback | System::SharedPtr<IFindResultCallback> | Callback object for saving replacement operation result IFindResultCallback. |
Remarks
The following sample code shows how to replace one speified string with another speified string.
auto presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");
auto shape = System::ExplicitCast<AutoShape>(presentation->get_Slide(0)->get_Shape(0));
auto textSearchOptions = System::MakeObject<TextSearchOptions>();
textSearchOptions->set_WholeWordsOnly(true);
// Replace all separate 'the' occurrences with '<em><strong>'
shape->get_TextFrame()->ReplaceText(u"the", u"</strong></em>", textSearchOptions, nullptr);
presentation->Save(u"SomePresentation-out2.pptx", SaveFormat::Pptx);
See Also
- Typedef SharedPtr
- Class String
- Class ITextSearchOptions
- Class IFindResultCallback
- Class TextFrame
- Namespace Aspose::Slides
- Library Aspose.Slides