Articles in this section
Category / Section

How to merge or combine multiple PowerPoint files in C#, VB.NET

1 min read

Syncfusion Essential Presentation is a .NET PowerPoint library used to create, open, read, edit, combine and convert PowerPoint presentations. The library supports combine/merge PowerPoint slides with below paste options equivalent to Microsoft PowerPoint. 

 

  • Keep Source Formatting – This implies that the slide will keep its original theme format by maintaining the theme of presentation you are copying from.
  • Use Destination Theme - This will adapt the copied slide to match the destination theme by taking the theme of the destination presentation.

Steps to combine PowerPoint programmatically:

  1. Create a new C# console application.

Create console application

 

  1. Install Syncfusion.Presentation.Base NuGet package to the console application project from nuget.org. For more information about adding a NuGet feed in Visual Studio and installing NuGet packages, refer to documentation

 

NuGet packages

 

  1. Include the following namespace in the Program.cs file.
using Syncfusion.Presentation;

 

Imports Syncfusion.Presentation

 

The following example demonstrates how to copy a PowerPoint slide from a PowerPoint presentation and paste it to another PowerPoint presentation.

 

//Open the source PowerPoint from which to copy a slide.
IPresentation powerpointSrcDoc = Presentation.Open("SourcePowerPointFile.pptx");
 
//Open the destination PowerPoint to paste the slide.
IPresentation powerpointDestDoc = Presentation.Open("DestinationPowerPointFile.pptx");
 
//Copy the first slide in the source PowerPoint file. Any slides can be chosen with its index position.
ISlide slide = powerpointDestDoc.Slides[0].Clone();
 
//Merge the cloned slide to the destination Presentation with 'SourceFormatting' paste option.
powerpointDestDoc.Slides.Add(slide, PasteOptions.SourceFormatting, powerpointSrcDoc);
 
//Close the source presentation.
powerpointSrcDoc.Close();
 
//Save the destination presentation.
powerpointDestDoc.Save("DestinationPowerPointFile.pptx");
 
//Close the destination presentation.
powerpointDestDoc.Close();

 

'Open the source PowerPoint from which to copy a slide.
Dim powerpointSrcDoc As IPresentation = Presentation.Open("SourcePowerPointFile.pptx")
 
'Open the destination PowerPoint to paste the slide.
Dim powerpointDestDoc As IPresentation = Presentation.Open("DestinationPowerPointFile.pptx")
 
'Copy the first slide in the source PowerPoint file. Any slides can be chosen with its index position.
Dim slide As ISlide = powerpointDestDoc.Slides(0).Clone()
 
'Merge the cloned slide to the destination Presentation with 'SourceFormatting' paste option.
powerpointDestDoc.Slides.Add(slide, PasteOptions.SourceFormatting, powerpointSrcDoc)
 
'Close the source presentation.
powerpointSrcDoc.Close()
 
'Save the destination presentation.
powerpointDestDoc.Save("DestinationPowerPointFile.pptx")
 
'Close the destination presentation.
powerpointDestDoc.Close()

 

You can download the working sample from Combine-PowerPoint.Zip.

Take a moment to peruse the documentation, where you can find options to combine the PowerPoint slides with code examples.

An online sample link to Combine PowerPoint slides

Refer here to explore the rich set of Syncfusion Essential Presentation features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied