Free Support Forum - aspose.com

How to insert slide from another ppt into the end of the given PPT (VB .NET)

Hi, Support,

I used aspose.slides.dll on VB.net and expect to insert slide from another ppt into the end of the given ppt, for example:
PPT1.ppt has 10 slides, and PPT2.ppt has 3 slides. I want to take the first slide out of PPT2.ppt,and then insert it into the end of the PPT1.ppt, as a result, the PPT1.ppt will has 11 slides.
How to work it out?

Thanks for you help.

Ducaisoft

@ducaisoft,

You can explore the slide cloning feature to copy presentation slides from one presentation to another. Please visit this documentation link for your kind reference.

Thank you for your reference.
Would you please show me the code how it work?

@ducaisoft,

Please refer to this particular example in link that I have shared earlier with you.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

// Instantiate Presentation class to load the source presentation file
using (Presentation srcPres = new Presentation(dataDir + "CloneAtEndOfAnother.pptx"))
{
    // Instantiate Presentation class for destination PPTX (where slide is to be cloned)
    using (Presentation destPres = new Presentation())
    {
        // Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
        ISlideCollection slds = destPres.Slides;

        slds.AddClone(srcPres.Slides[0]);

        // Write the destination presentation to disk
        destPres.Save(dataDir + "Aspose2_out.pptx", SaveFormat.Pptx);
    }
}