Finding and replacing text is a common task that you may need to do often. In the case of multiple files, doing this programmatically will prove to be more efficient. To that end, this article will teach you how to find and replace text in PowerPoint files using C++.
- C++ API for Finding and Replacing Text in PowerPoint Presentations
- Find and Replace Text in PowerPoint Files
C++ API for Finding and Replacing Text in PowerPoint Presentations
Aspose.Slides for C++ is a C++ API for working with PowerPoint files. It enables you to create, read and update PowerPoint files without needing Microsoft PowerPoint to be installed. Furthermore, the API allows you to find and replace text in PowerPoint presentations. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Find and Replace Text in PowerPoint Files using C++
The following are the steps to find and replace text in PowerPoint files.
- Firstly, load the PowerPoint file using the Presentation class.
- Loop through the slides of the presentation.
- Within the loop, retrieve the text frames in an ITextFrame array.
- Loop through the array of the text frames.
- Within the loop, iterate through the paragraphs in each ITextFrame.
- Iterate through the portions in each IParagraph.
- For each IPortion, check if it contains the desired text. If it exists, then replace the text.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to find and replace text in PowerPoint files using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to find and replace text in PowerPoint presentations using C++. The shared code snippet shows how to achieve that with just a few lines of code. Aspose.Slides for C++ is a robust and feature-rich API that provides many additional features for automating your PowerPoint workflows. You can explore the API in detail by visiting the official documentation. In case of any queries, please feel free to reach us at our free support forum.