Add a Section in PowerPoint in C#, VB.NET

In this article, we will introduce the following methods to add a section to a PowerPoint document by using Spire.Presentation for .NET:

  • Add a section at the end of a PowerPoint document
  • Insert a section at a specified position
  • Add a section before a specified slide

Add a section at the end of a PowerPoint document

C#
//Load a PowerPoint document
Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");
//Add a section at the end of the document
Section section = ppt.SectionList.Append("New Section");            
//Save the result document
ppt.SaveToFile("AddSection.pptx", FileFormat.Pptx2013);
VB.NET
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("Input.pptx")
Dim section As Section = ppt.SectionList.Append("New Section")
ppt.SaveToFile("AddSection.pptx", FileFormat.Pptx2013)

Add a Section in PowerPoint in C#, VB.NET

Insert a section at a specified position

C#
//Load a PowerPoint document
Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");
//Insert a section at the first index position
Section section = ppt.SectionList.Insert(0, "New Section");            
//Save the result document
ppt.SaveToFile("InsertSectionAtSpecifiedPosition.pptx", FileFormat.Pptx2013); 
VB.NET
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("Input.pptx")
Dim section As Section = ppt.SectionList.Insert(0, "New Section")
ppt.SaveToFile("InsertSectionAtSpecifiedPosition.pptx", FileFormat.Pptx2013)

Add a Section in PowerPoint in C#, VB.NET

Add a section before a specified slide

C#
//Load a PowerPoint document
Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");
//Add a section before the second slide
Section section = ppt.SectionList.Add("New Section", ppt.Slides[1]);
//Save the result document
ppt.SaveToFile("AddSectionBeforeSlide.pptx", FileFormat.Pptx2013);
VB.NET
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("Input.pptx")
Dim section As Section = ppt.SectionList.Add("New Section", ppt.Slides(1))
ppt.SaveToFile("AddSectionBeforeSlide.pptx", FileFormat.Pptx2013)

Add a Section in PowerPoint in C#, VB.NET