I am trying to programmatically copy a slide into a PowerPoint presentation and paste it right after the original.
My first thought was to get the index of the old slide and add a copy to the desired new index, but I cannot find an easy way to get this index. I expected to have something like Slides.IndexOf(Slide slide)that, but could not find anything like it. I ended up writing old school code that seems to work, but I'm curious if there is a better way to do this.
var slide = (PowerPoint.Slide)powerpoint.ActiveWindow.View.Slide;
var slideIndex = 0;
for (int index = 1; index <= presentation.Slides.Count; index++)
{
if (presentation.Slides[index] == slide)
{
slideIndex = index;
break;
}
}
This is C # / VSTO, but any input that can put me on the right path is appreciated, be it VBA or VB!
source
share