Search code examples
c#powerpoint

How to find current slide in Powerpoint Slideshow Window


I create a Powerpoint add-in and I need to find which slide is active in Slideshow Window. I have this code:

if (Globals.ThisAddIn.Application.SlideShowWindows.Count > 0)
{
for (int s = 0; s < Globals.ThisAddIn.Application.ActivePresentation.Slides.Count; s++)
{
//abc
}
}

So I check if slideshow window is running and then go through all slides in presentation. But this is not very good solution. I want to get current slide immediately.


Solution

  • Here's the VBA to do what you want. It returns the index of the active slide in the first slideshow window:

    SlideShowWindows(1).View.Slide.SlideIndex