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, etc. The manual way of copying/pasting the content may not be suitable when dealing with several presentations. Therefore, this article lets the .NET developers learn how to merge PowerPoint PPT presentations programmatically in C#.

C# .NET PowerPoint Merger API - Free Download

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 in 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 PPT in C#

In the previous example, we merged all the slides from the source PPTX file into the target PPTX. However, there might be a 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 PPT using C#.

Merged Presentation

merged powerpoint presentation using C#

C# Use Slide Master while Merging PowerPoint PPTX

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.Slides1, presentation1.Masters[0], true)]12 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#

C# API To Merge PowerPoint PPT - Get a Free License

You can get a free temporary license to use the API without evaluation limitations.

Conclusion

In this article, you have learned how to merge two or multiple PowerPoint presentations using C#. You can port the C# code samples 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

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