We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback


Trusted by the world’s leading companies

Overview

The Syncfusion .NET PowerPoint Library allows you to find and replace text in a PowerPoint with other text in all PowerPoint slides and elements, such as shapes, text boxes, tables, and SmartArt. It provides options to find text by matching case and whole words.


How to find and replace text in a PowerPoint using C#

  1. Install NuGet package: Install the Syncfusion.Presentation.Net.Core NuGet package in your project.
  2. Open the presentation: Create a FileStream object to represent the input presentation.
  3. Load in .NET PowerPoint Library: Create an IPresentation object by passing the FileStream object.
  4. Find text: Use the FindAll method to find all occurrences of the word ‘product’ in the PowerPoint presentation.
  5. Replace text: Iterate through each text match, using the GetAsOneTextPart method to obtain the matching text as a single text part, and then replace the text.
  6. Save the presentation: Save the IPresentation object to the FileStream object.

Here is an example of how to find and replace text in a PowerPoint using C# using the Syncfusion .NET PowerPoint Library.

//Open an existing presentation.           
using FileStream inputStream = new FileStream("Template.pptx", FileMode.Open);
using IPresentation pptxDoc = Presentation.Open(inputStream);

//Find all the occurrences of particular text in the PowerPoint presentation.
ITextSelection[] textSelections = pptxDoc.FindAll("product", false, false);
foreach (ITextSelection textSelection in textSelections)
{
    //Get the found text as a single text part.
    ITextPart textPart = textSelection.GetAsOneTextPart();
    //Replace the text.
    textPart.Text = "Service";
}

//Save the presentation.
using FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create);
pptxDoc.Save(outputStream);

Find options

Find text

Find the text in a presentation based on a specific pattern using a regular expression (regex) or normal string. Find it in the entire presentation or within a specific slide.

Casing and whole-word matches

Refine the find operation by matching the casing or whole word for more precise results.

Find first

Find only the first occurrence of a piece of text in the presentation.

Find all

Find all the occurrences of the given text in all parts of the presentation, including the shapes, text boxes, tables, and SmartArt.



Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.

Scroll up icon