Clone Slides in PowerPoint Presentations using C#

Clone Slides in PowerPoint C#

In certain cases, you may need to clone the slides in PowerPoint presentations. The cloning process makes the copy of a slide within or in another presentation without changing the original slide. In this article, you will learn how to automate slide cloning in PowerPoint presentations. Particularly, the article will cover how to clone slides within a PowerPoint presentation or from one presentation to another using C#.

.NET API to Clone Slides in PowerPoint Presentations

In order to clone slides in PPTX or PPT presentations, we will use Aspose.Slides for .NET. It is a presentation manipulation API that lets you create, modify and convert PowerPoint and OpenOffice presentations. You can either download the API or install it using NuGet.

PM> Install-Package Aspose.Slides.NET

Clone Slides within a PowerPoint Presentation in C#

You can clone a slide either at a specified location or at the end of the PowerPoint presentation. The following sections demonstrate each of the above-mentioned scenarios with code samples.

Clone Slide at the End of Presentation

The following are the steps to clone a slide at the end of a PowerPoint presentation using C#.

  1. First, load the PowerPoint presentation using Presentation class.
  2. Get reference of the slide collection using Presentation.Slides into an ISlideCollection object.
  3. Clone desired slide using ISlideCollection.AddClone(ISlide) method by specifying the slide to be cloned as a parameter.
  4. Finally, save the presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to clone a slide at the end of the PowerPoint presentation.

Clone Slide to a Specific Position in Presentation

The following are the steps to clone a slide at a specific position in the PowerPoint presentation using C#.

  1. Load the PowerPoint presentation using Presentation class.
  2. Get reference of the slide collection using Presentation.Slides into an ISlideCollection object.
  3. Clone desired slide using ISlideCollection.InsertClone(Int32, ISlide) method by specifying the destination index and slide to be cloned as parameters.
  4. Save the presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to clone a slide at a specific position in a PowerPoint presentation.

Clone Slides into Another Presentation using C#

In this section, you will learn how to clone a slide from one presentation to another. The following subsections will cover the cloning of a slide at the end or at a specific position in the destination presentation.

Clone Slide at the End of Another Presentation

The following are the steps to clone a slide at the end of another presentation using C#.

  1. Load the source PowerPoint presentation using Presentation class.
  2. Load the destination PowerPoint presentation using Presentation class.
  3. Get reference of the slide collection from destination presentation into an ISlideCollection object.
  4. Clone desired slide using ISlideCollection.AddClone(ISlide) method by specifying the slide to be cloned as a parameter.
  5. Save the destination presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to clone a slide from one presentation to another.

Clone Slide to a Specific Position in Another Presentation

The following are the steps to clone a slide at a specific location in another presentation using C#.

  1. Load the source PowerPoint presentation using Presentation class.
  2. Load the destination PowerPoint presentation using Presentation class.
  3. Get reference of the slide collection from destination presentation into an ISlideCollection object.
  4. Clone desired slide using ISlideCollection.InsertClone(Int32, ISlide) method by specifying the destination index and slide to be cloned as parameters.
  5. Save the destination presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to clone a slide into another PowerPoint presentation.

Get a Free API License

You can use Aspose.Slides for .NET without evaluation limitations by requesting a temporary license.

Tip: You may want to check out Aspose FREE PowerPoint Splitter used to split the slides in presentations and save them as separate files.

Conclusion

In this article, you have learned how to clone slides in PowerPoint presentations using C#. The article explicitly covered the cloning of slides within a presentation or from one presentation to another. In addition, you can visit the documentation to explore other features of API. Also, you can feel free to let us know about your queries via our forum.

See Also