This short article explains how to find and replace text in PowerPoint using C#. It provides the IDE settings, a list of steps, and sample code to replace words in PowerPoint using C#. You will learn various techniques to perform the same operation in a PowerPoint presentation.
Passaggi per trovare e sostituire in PowerPoint usando C#
- Set up the environment to use Aspose.Slides for .NET for text replacement.
- Upload the source PPTX into the class object Presentation to replace the words.
- Iterate through each slide in the uploaded presentation.
- Retrieve all text boxes from the current slide.
- Scorri ogni paragraph e la porzione di testo nella casella di testo.
- Check each portion of text to find the target string without case sensitivity.
- Reconstruct the text in the portion by replacing the old value with the new one.
- Finally, save the modified presentation to 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 analyze each portion of the paragraph collection for each text box. Check each portion of text for the target string, then reconstruct it by replacing the old text with the new one.
Code to find and replace in PowerPoint using C#
This code shows the process to find and replace text in PowerPoint. It is also possible to use Aspose.Slides.Util.SlideUtil.FindAndReplaceText() to replace the text throughout 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 explains the process of searching and replacing text in a presentation. To extract media such as audio or video from a presentation, see the article Extract Media from PowerPoint using C#.