Free Support Forum - aspose.com

Merging presentations- never returns from Write

Hi,

We are trying to get all the slides from multiple presentations into a single presentation.

In almost all cases, the call to .Write simply hangs.

We are using Aspose.Slides 4.0.0.0

Below is simplified code that causes the problem, and attached are the files used for the test.

I would appreciate any help with this.

===== begin code =====

Dim DestinationPresentation As New Presentation()

Dim SourcePresentation As Presentation

SourcePresentation = New Presentation("C:\Slide.ppt")

For Each currentSlide As Slide In SourcePresentation.Slides

Dim NewSlide As Aspose.Slides.Slide

NewSlide = DestinationPresentation.CloneSlide(currentSlide, DestinationPresentation.Slides.Count - 1)

Next

SourcePresentation = New Presentation("C:\Slides.ppt")

For Each currentSlide As Slide In SourcePresentation.Slides

Dim NewSlide As Aspose.Slides.Slide

NewSlide = DestinationPresentation.CloneSlide(currentSlide, DestinationPresentation.Slides.Count - 1)

Next

DestinationPresentation.Write("C:\DEST.ppt")

===== end code =====

Hi,

Thanks for your interest in Aspose.Slides.

The clone method used in the code snippet that you have provided, actually clone the slides within same presentation. In order to clone slides from different presentations, please use the code snippet below.

[VB .NET]

Dim DestinationPresentation As New Aspose.Slides.Presentation()

Dim SourcePresentation As Aspose.Slides.Presentation

SourcePresentation = New Aspose.Slides.Presentation("D:\ppt\SourceSlides\Slide.ppt")

Dim sList As SortedList = New SortedList()

Dim NewSlide As Aspose.Slides.Slide

Dim i As Integer = 1

For i = 0 To SourcePresentation.Slides.Count - 1

NewSlide = SourcePresentation.CloneSlide(SourcePresentation.Slides(i), DestinationPresentation.Slides.LastSlidePosition + 1, DestinationPresentation, sList)

Next

SourcePresentation = New Aspose.Slides.Presentation("d:\ppt\SourceSlides\Slides.ppt")

For i = 0 To SourcePresentation.Slides.Count - 1

NewSlide = SourcePresentation.CloneSlide(SourcePresentation.Slides(i), DestinationPresentation.Slides.LastSlidePosition + 1, DestinationPresentation, sList)

Next

DestinationPresentation.Slides.RemoveAt(0)

DestinationPresentation.Write("D:\ppt\SourceSlides\DEST.ppt")

Thanks and Regards,

Thank you very much, this works properly.