Merge PowerPoint Presentations using C# or VB.NET

Merge PowerPoint files in C#

Merging PowerPoint presentations can be useful in various scenarios such as combining content from multiple PPT/PPTX, merging parts of a single presentation created by two or more people, and etc. The manual way of copying/pasting the content may not be suitable when dealing with a number of presentations. Therefore, this article lets the .NET developers learn how to merge PowerPoint presentations programmatically using C#.

TIP: You may be interested in trying out a web viewer app for presentations developed with Aspose’s APIs.

.NET PowerPoint Merger API

Aspose.Slides for .NET is a feature-rich .NET PowerPoint API that lets you create and manipulate presentation documents. Along with that, it allows you to combine two or more PowerPoint presentations using C# or VB.NET. You can download the API’s DLL or install it using NuGet.

Merge PowerPoint Presentations using C#

In this section, you will learn how to clone and merge all the slides from one PowerPoint presentation to another. For this, you can simply clone the slides from the source presentation and add them at the end of the target presentation. The following are the steps to merge two presentations.

The following code sample shows how to merge two PowerPoint presentations using C#.

Target Presentation

target powerpoint presentation

Source Presentation

source powerpoint presentation to be merged

Merged Presentation

merge powerpoint presentation C#

Merge Particular Slides of PowerPoint Presentations using C#

In the previous example, you have merged all the slides from the source PPTX file into the target PPTX. However, there might be the case when you need to merge only the selected slides. In such a case, you can specify the slides to be merged using the slide’s index. The following are the steps to perform this operation.

  • Load the target presentation using the Presentation class.
  • Load the source presentation using the Presentation class.
  • Clone the desired slides using presentation1.Slides.AddClone(presentation2.Slides[int Index]) method.
  • Save the merged presentation as a new PPTX file.

The following code sample shows how to merge particular slides of presentations using C#.

Merged Presentation

merged powerpoint presentation using C#

Use Slide Master while Merging PowerPoint Presentations

In both of the previous examples, you have merged the slides keeping the design and template of the source presentation. However, in certain cases, you may need to modify the layout of the slides in accordance with the target presentation. In such cases, you can use the overloaded presentation1.Slides.AddClone(presentation2.Slides[1], presentation1.Masters[0], true) method.

The following code sample shows how to merge the slides in PowerPoint presentation using the Slide Master in C#.

Merged Presentation

combined powerpoint presentation using C#

Conclusion

In this article, you have learned how to merge two or multiple PowerPoint presentations using C#. You can port the C# code samples in order to merge presentations using VB.NET. In case you want to explore more about Aspose’s .NET PowerPoint API, you can visit the documentation.

See Also