Remove Section in PowerPoint in C#, VB.NET

This article demonstrates how to remove a specific section or all the sections but keep the slide(s) in the section(s) in PowerPoint by using Spire.Presentation for .NET.

Below is the screenshot of the input PowerPoint document which contains two sections:

Remove Section in PowerPoint in C#, VB.NET

C#
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load a PowerPoint document
ppt.LoadFromFile("AddSection.pptx");

//Remove the second section
ppt.SectionList.RemoveAt(1);

//Remove all the sections
//ppt.SectionList.RemoveAll();

//Save the result document
ppt.SaveToFile("RemoveSection.pptx", FileFormat.Pptx2013);
VB.NET
'Create a Presentation instance
Dim ppt As Presentation = New Presentation
'Load a PowerPoint document
ppt.LoadFromFile("AddSection.pptx")
'Remove the second section
ppt.SectionList.RemoveAt(1)
'Remove all the sections
'ppt.SectionList.RemoveAll()
'Save the result document
ppt.SaveToFile("RemoveSection.pptx", FileFormat.Pptx2013)

The output PowerPoint document after removing the second section:

Remove Section in PowerPoint in C#, VB.NET