Slide cloning feature provided by Spire.Presentation enables developers to clone one or several slides within one PowerPoint presentation or among multiple presentations. By cloning slide from source presentation to target document, we can easily split a large presentation into small ones and merge multiple presentations to one presentation in reverse. This article presents how to merge selected slides from multiple PowerPoint presentations into one single presentation.
Main Steps
Step 1: Create a new PowerPoint document and remove the default blank slide.
Presentation ppt = new Presentation(); ppt.Slides.RemoveAt(0);
Step 2: Initialize two instances of Presentation class and load the sample PowerPoint file respectively.
Presentation ppt1 = new Presentation("sample_01.pptx",FileFormat.Pptx2010);
Presentation ppt2 = new Presentation("sample_02.pptx", FileFormat.Pptx2010);
Step 3: Append all slides in sample_01 to the new PowerPoint document using method Append(ISlide slide).
for (int i = 0; i < ppt1.Slides.Count; i++)
{
ppt.Slides.Append(ppt1.Slides[i]);
}
Step 4: Append the second slide in sample_02 to the new presentation.
ppt.Slides.Append(ppt2.Slides[1]);
Step 5: Save and launch the file.
ppt.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
Output

Entire Code
using Spire.Presentation;
namespace MergeSlides
{
class Program
{
static void Main(string[] args)
{
Presentation ppt = new Presentation();
Presentation ppt1 = new Presentation("sample_01.pptx", FileFormat.Pptx2010);
Presentation ppt2 = new Presentation("sample_02.pptx", FileFormat.Pptx2010);
ppt.Slides.RemoveAt(0);
//append all slides in ppt1 to ppt
for (int i = 0; i < ppt1.Slides.Count; i++)
{
ppt.Slides.Append(ppt1.Slides[i]);
}
//append the second slide in ppt2 to ppt
ppt.Slides.Append(ppt2.Slides[1]);
//save and launch the file
ppt.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
Imports Spire.Presentation
Namespace MergeSlides
Class Program
Private Shared Sub Main(args As String())
Dim ppt As New Presentation()
Dim ppt1 As New Presentation("sample_01.pptx", FileFormat.Pptx2010)
Dim ppt2 As New Presentation("sample_02.pptx", FileFormat.Pptx2010)
ppt.Slides.RemoveAt(0)
'append all slides in ppt1 to ppt
For i As Integer = 0 To ppt1.Slides.Count - 1
ppt.Slides.Append(ppt1.Slides(i))
Next
'append the second slide in ppt2 to ppt
ppt.Slides.Append(ppt2.Slides(1))
'save and launch the file
ppt.SaveToFile("result.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("result.pptx")
End Sub
End Class
End Namespace
