Free Support Forum - aspose.com

RemoveAt is not working properly....!?

I created Template PowerPoint it contains some empty slides. I need to remove some empty slide i wrote code here

If PCount = 1 Then

pres.Slides.RemoveAt(pres.Slides.LastSlidePosition - 83)

pres.Slides.RemoveAt(pres.Slides.LastSlidePosition - 82)

ElseIf PCount = 2 Then

pres.Slides.RemoveAt(pres.Slides.LastSlidePosition - 82)

End If

It work but given the number is not exactly deleted, it give some other number is deleted

For Example: Say slide no 30 should delete slide 30 but slide 38 is deleted

Reply me ASAP.

Hello sridhar_siv.

Slides.RemoveAt() removes slide with specified index, not position. To remove slide with specified position use Presentation.GetSlideByPosition() and Slides.Remove() pair.

Hi

Thanks for your reply,

Still i am having same problem.
I used like this
pres.Slides.Remove(pres.GetSlideByPosition(31))

Can you explain me how to remove slide 31 from powerpoint.

Thanks
Sridhar

You did it right. This line will remove 31st slide from the presentation.

Please note that Slide.Position has nothing to do with an index in Slides collection. Every visible slide in presentation has an unique position >= 1 (there can be many slides with position == 0, but they are masters and invisible in presentation). Slide’s position is equal to a number, displayed near slide in slides list in PowerPoint.

Thanks you very Much Automobile [au]

Regards,
Sridharan.