CloneSlide results in missing images


#1

I am trying to merge a number of powerpoint presentations together.

Unfortuantely the merged presentation is missing pictures from the second presentation.

The following code is being used to copy the slides from one presentation to another (as you can see even if I manually copy the images across, it still is not working correctly).

Regards

private static void CopySlidesToOutput(Presentation sourcePres, Presentation outputPres)

{

SortedList temp = new SortedList();

for (int i = 0; i < sourcePres.Slides.Count; i++)

{

Slide s = outputPres.CloneSlide(sourcePres.SlidesIdea, outputPres.Slides.Count, outputPres, temp);

}

for(int i = 0; i < sourcePres.Pictures.Count; i++)

{

int newPicId = outputPres.Pictures.Add(sourcePres.PicturesIdea);

System.Console.Out.WriteLine(“Copied picture {0} to presentation as {1}”, i, newPicId);

}

System.Console.Out.WriteLine(sourcePres.Title);

}


#2

Dear Stef,

1. You should call CloneSlide function of source presentation:

SortedList temp = new SortedList();
for (int i = 0; i < sourcePres.Slides.Count; i++) {
Slide s = sourcePres.CloneSlide(sourcePres.Slides[ i ], outputPres.Slides.LastSlidePosition + 1, outputPres, temp);
}

2. You can’t add pictures from one presentation to another because each picture attached to the own presentation and can’t work with another one.
You should create new picture at first:

Picture newpic = new Picture(outputPres, sourcePres.Pictures[ i ].Image);
int newPicId = outputPres.Pictures.Add(newpic);

But CloneSlide will do all these things for you so don’t think about it.


#3

Alcrus

This is now working.

Thanks for the speedy response…

Regards

Stef Shoffren