Problem cloning PPTX slides

I have problems cloning some PPTX slides. The error message is “Oject reference not set to an instance of an object”. I do not have problems cloning simple slides with just text, bullet points, etc. However when the slides are more complicated, for example, with graphs, the program would run into this problem. I am attaching two sample presentations. The program has no problem cloning the first three slides. It would fail on the last slide. I suspect it has something to do with the nature of the last slide. The program can complete successfully if I change the loop to stop cloning before the last slide.

The test program is I use is shown below:

Public Sub CloneSlideEx()
Dim srcPres As PresentationEx = New PresentationEx("…/…/Original.ForAspose1.pptx")
Dim targetPres As PresentationEx = New PresentationEx("…/…/out.pptx")
For i As Integer = 0 To srcPres.Slides.Count - 1
Dim srcSlide As SlideEx = srcPres.Slides(i)
Dim srcSlideMaster As MasterSlideEx = srcSlide.LayoutSlide.MasterSlide
Dim index As Integer = targetPres.Masters.AddClone(srcSlideMaster)
Dim targetSlideMaster As MasterSlideEx = targetPres.Masters(index)
targetPres.Slides.AddClone(srcSlide, targetSlideMaster)
Next
targetPres.Write("…/…/Output/output.pptx")
End Sub

Thank you for the example. We will investigate it and fix.

Thank you for the quick response. I gather you have already found the sample slides I provided in a separate posting.

Any update on this problem?

Hi BrightStar,

Your code and slides are working fine on my end. Please download the latest version here and test it.

Yes. I do see the latest version 3.1.1.7 does fix the problem. Thanks a lot.