Free Support Forum - aspose.com

Exception: Slide is not a master slide

Hi

I am getting the exception “Slide is not a master slide”, while changing the master slide of a slide. The following code snippet is used to change the master,

Slide clonedSlide = masterTemplate.CloneSlide(masterTemplate.GetSlideByPosition(1), presentation.Slides.LastSlidePosition + 1, presentation, sList);
Slide masterSlide = presentation.GetSlideById(clonedSlide.MasterId);
foreach (Slide slide in presentation.Slides)
{
slide.ChangeMaster(masterSlide);
}

I have attached the master template for which I am getting this issue. For any other template I am not getting this issue. Please help me to find out where the issue lies.

Thanks
Vijay

Dear Vijay,

Make sure, you are passing new object of sorted list. I have sucessfully changed the master of all slides taken from your presentation, here is a source code.

C#

--------------------------------------------------------------------------------------------------------------

Presentation presentation = new Presentation(@"c:\source\-Presentation1.ppt");

Presentation masterTemplate = new Presentation(@"c:\source\PPT+Standard.ppt");

Slide clonedSlide = masterTemplate.CloneSlide(masterTemplate.GetSlideByPosition(1),

presentation.Slides.LastSlidePosition + 1, presentation, new SortedList() );

Slide masterSlide = presentation.GetSlideById(clonedSlide.MasterId);

foreach (Slide slide in presentation.Slides)

{

slide.ChangeMaster(masterSlide);

}

presentation.Write("c:\\out.ppt");

Shakeel Faiz,

Thank you for your inputs. Using a new SortedList object, solves this issue.

Thanks
Vijay