This quick article explains how to find and replace text in PowerPoint using C#. It provides IDE settings, a list of steps, and a sample code to replace words in PowerPoint using C#. You will learn different techniques to perform the same task in the PowerPoint presentation.
Steps to Find and Replace in PowerPoint using C#
- Set the environment to use Aspose.Slides for .NET for replacing text
- Load the source PPTX into the Presentation class object for replacing words
- Iterate through each slide in the loaded presentation
- Retrieve all text boxes from the current slide
- Loop through each paragraph and text portion in the text box
- Check each text portion for finding the target string without case sensitivity
- Reconstruct the text in the portion by replacing the old value with the new value
- Finally, save the modified presentation on disk
These steps describe how to find and replace text in PowerPoint using C#. Load the source presentation, iterate through each slide, retrieve all text boxes, and parse each portion of the paragraph collection for each text box. Check each text portion for the target string, then reconstruct it by replacing the old text with the new text.
Code to Search and Replace in PowerPoint using C#
This code shows the process to find and replace text in PowerPoint. You can also use Aspose.Slides.Util.SlideUtil.FindAndReplaceText() to replace text in the entire presentation using the appropriate arguments. The other option is to use ReplaceText() on a specific TextFrame with the desired TextSearchOptions settings.
This article teaches the process of finding and replacing text in a presentation. To extract media such as audio or video from a presentation, refer to the article Extract Media from PowerPoint using C#.