How to Split a PowerPoint Document into Individual Slides in C#, VB.NET

It must be time-consuming if you manually split a large PowerPoint document that contains a lot of slides into presentations that each contains one original slide. In this article, I'll introduce a simple solution for doing this using Spire.Presentation in C#, VB.NET.

The core thought in this solution is to create a new PowerPoint presentation and remove the blank slide, then clone the specified slide of original presentation to the new one.

Test File:

How to Split a PowerPoint Document into Individual Slides in C#, VB.NET

Code Snippet:

Step 1: Initialize a new instance of Presentation class.

Presentation ppt = new Presentation();

Step 2: Load the test file.

ppt.LoadFromFile("test.pptx");

Step 3: Initialize another instance of Presentation class, and remove the blank slide.

Presentation newppt = new Presentation();
newppt.Slides.RemoveAt(0);

Step 4: Append the specified slide from old presentation to the new one.

newppt.Slides.Append(ppt.Slides[0]);

Step 5: Save the file.

newppt.SaveToFile("result.pptx", FileFormat.Pptx2010);

Step 6: Use a for loop to export each slide in the presentation as individual slides.

Result:

How to Split a PowerPoint Document into Individual Slides in C#, VB.NET

Entire Code:

[C#]
using Spire.Presentation;
using System;
namespace SplitPPT
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("test.pptx");

            for (int i = 0; i < ppt.Slides.Count; i++)
            {
                Presentation newppt = new Presentation();
                newppt.Slides.RemoveAt(0);
                newppt.Slides.Append(ppt.Slides[i]);
                newppt.SaveToFile(String.Format("result-{0}.pptx", i), FileFormat.Pptx2010);

            }
        }
    }
}
[VB.NET]
Imports Spire.Presentation
Namespace SplitPPT
	Class Program
		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation()
			ppt.LoadFromFile("test.pptx")

			For i As Integer = 0 To ppt.Slides.Count - 1
				Dim newppt As New Presentation()
				newppt.Slides.RemoveAt(0)
				newppt.Slides.Append(ppt.Slides(i))

				newppt.SaveToFile([String].Format("result-{0}.pptx", i), FileFormat.Pptx2010)
			Next
		End Sub
	End Class
End Namespace