Free Support Forum - aspose.com

Creating slides by calling functions--Please consider this version instead!

Hi,

I am trying to write a C# program that creates a presentation MyPres (with 30 slides), where each slide is created by a function MakeSlide(), that returns a slide. This is my sample code:

Presentation MyPres = New Presentation();

Slide[] MyPresSlideDeck = new Slide[30];

for(i=0;i<30;i++){

MyPresSlideDeck[i] = MakeSlide(.....);

}

for(i=0;i<29;i++){

Systems.Collections.SortedList slist = new Systems.Collections.SortedList();

MyPres[i].CloneSlide(MyPresSlideDeck[i], MyPres.Slides.LastSlidePosition+1, MyPres, slist);

}

MyPres.Write("Output path for file");

....

protected slide MakeSlide(){.......}

Am I on the right track, or am I writing something wrong?Thanks!!

Dear AsAd,

In order to create a slide inside the presentation, you need the presentation object. So you will have to pass MyPres as a parameter to MakeSlide function.

For example it will look like this

Slide MakeSlide(Presentation srcPres)

{

Slide sld=srcPres.AddEmptySlide();

return sld;

}

The rest code seems ok.