Add new slide in PowerPoint document

Spire.Presentation for .NET, a reliable .NET PPT component, enables you to generate, read, edit, convert even print your PPT documents without installing Microsoft PowerPoint on your machine. It also includes many useful features, for example, the functionality of adding new slide in PPT document.

Using the Spire.presention you can use the presentation.Slides.Append() method to add new slide in your PPT document with C#, VB.NET. Please see the target PPT document with new slide as below pictures:

Add new slide in PPT document

Add new slide in PPT document

There is a guide to introduce a method to add new slide to achieve above screenshots with C#, VB.NET via Spire.Presentation for .NET.

The main steps of method are:

Step 1: Create a PPT document and use presentation.Slides.Append() method to add new slide.

Presentation presentation = new Presentation();
presentation.Slides.Append();

Step 2: Set background and add shape to show text.

string ImageFile = @" bg.png";
RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
presentation.Slides[i].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
presentation.Slides[i].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
//append new shape  
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 200));

Step 3: Save the PPT document.

presentation.SaveToFile("slide.pptx", FileFormat.Pptx2010);

Download and install Spire.Presentation for .NET and use below code to experience this method to add new slide in PPT document.

The full code:

[C#]
using System.Drawing;
using Spire.Presentation;
using Spire.Presentation.Drawing;

namespace Add_new_slide_in_PowerPoint_document
{
    class Program
    {
        static void Main(string[] args)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //add new slide
            presentation.Slides.Append();

            //set the background image
            for (int i = 0; i < 2; i++)
            {
                string ImageFile = @" bg.png";
                RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
                presentation.Slides[i].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
                presentation.Slides[i].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
            }

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 200));
            shape.ShapeStyle.LineColor.Color = Color.White;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;

            //add text to shape
            shape.AppendTextFrame("The sample demonstrates how to set Animations in PPT using Spire.Presentation.");

            //add new paragraph
            shape.TextFrame.Paragraphs.Append(new TextParagraph());

            //add text to paragraph
            shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue."));

            //set the Font
            foreach (TextParagraph para in shape.TextFrame.Paragraphs)
            {
                para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
                para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                para.Alignment = TextAlignmentType.Left;
                para.Indent = 35;
            }

             //append new shape
            shape = presentation.Slides[1].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 200, 600, 50));
            shape.ShapeStyle.LineColor.Color = Color.White;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;

            //add text to shape
            shape.AppendTextFrame("This is newly added Slide.");

            //set the Font
            shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;
            shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
            shape.TextFrame.Paragraphs[0].Indent = 35;

            //save the document
            presentation.SaveToFile("slide.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("slide.pptx");
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports Spire.Presentation
Imports Spire.Presentation.Drawing

Namespace Add_new_slide_in_PowerPoint_document
	Class Program
		Private Shared Sub Main(args As String())
			'create PPT document
			Dim presentation As New Presentation()

			'add new slide
			presentation.Slides.Append()

			'set the background image
			For i As Integer = 0 To 1
				Dim ImageFile As String = " bg.png"
				Dim rect As New RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height)
				presentation.Slides(i).Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect)
				presentation.Slides(i).Shapes(0).Line.FillFormat.SolidFillColor.Color = Color.FloralWhite
			Next

			'append new shape
			Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 150, 600, 200))
			shape.ShapeStyle.LineColor.Color = Color.White
			shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None

			'add text to shape
			shape.AppendTextFrame("The sample demonstrates how to set Animations in PPT using Spire.Presentation.")

			'add new paragraph
			shape.TextFrame.Paragraphs.Append(New TextParagraph())

			'add text to paragraph
			shape.TextFrame.Paragraphs(1).TextRanges.Append(New TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue."))

			'set the Font
			For Each para As TextParagraph In shape.TextFrame.Paragraphs
				para.TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
				para.TextRanges(0).Fill.FillType = FillFormatType.Solid
				para.TextRanges(0).Fill.SolidColor.Color = Color.Black
				para.Alignment = TextAlignmentType.Left
				para.Indent = 35
			Next

			'append new shape
			shape = presentation.Slides(1).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 200, 600, 50))
			shape.ShapeStyle.LineColor.Color = Color.White
			shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None

			'add text to shape
			shape.AppendTextFrame("This is newly added Slide.")

			'set the Font
			shape.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
			shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid
			shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black
			shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left
			shape.TextFrame.Paragraphs(0).Indent = 35

			'save the document
			presentation.SaveToFile("slide.pptx", FileFormat.Pptx2010)
			System.Diagnostics.Process.Start("slide.pptx")
		End Sub
	End Class
End Namespace

If you couldn't successfully use the Spire.presentation, please refer the Spire.Presentation Quick Start which can guide you quickly use the Spire.presentation.