Detect the used themes in PowerPoint in C#

This article demonstrates how to detect the used themes in a PowerPoint document using Spire.Presentation.

Detail steps:

Step 1: Instantiate a Presentation object and load the PowerPoint document.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"Sample.pptx");

Step 2: Get the theme name of each slide in the document.

StringBuilder sb = new StringBuilder();
string themeName = null;

foreach (ISlide slide in ppt.Slides)
{
    themeName = slide.Theme.Name;
    sb.AppendLine(themeName);
}

Step 3: Save to a .txt file.

File.WriteAllText("themeName.txt", sb.ToString());

Output:

Detect the used themes in PowerPoint in C#

Full code:

//Instantiate a Presentation object
Presentation ppt = new Presentation();
//Load the PowerPoint document
ppt.LoadFromFile(@"Sample.pptx");

StringBuilder sb = new StringBuilder();
string themeName = null;

//Get the theme name of each slide in the document
foreach (ISlide slide in ppt.Slides)
{
    themeName = slide.Theme.Name;
    sb.AppendLine(themeName);
}

//Save to a .txt file
File.WriteAllText("themeName.txt", sb.ToString());