none
Powerpoint vba or c# - How to get the actual next slide on SlideShowNextSlide event handler RRS feed

  • Question

  • The SlideShowNextSlide event handler passes the last active slide instead of the next slide. And this may be because it fires before the show moves to the next slide.

    Now I could use this way to figure the index of the slide next to the last one like:

    void ThisAddIn_SlideShowNextSlide(PowerPoint.SlideShowWindow Wn)
    {
        int slideIndex = Wn.View.Slide.SlideIndex + 1 ;
        // rest of the code ...
    }

    but this is not efficient and will fail in case of a loop presentation.

    And something like this won't work either, and still return the index of the last active slide and not the actual next slide.

    void ThisAddIn_SlideShowNextSlide(PowerPoint.SlideShowWindow Wn)
    {
        new System.Threading.Timer(_ => OnSlideChanged(Wn), null, 250, System.Threading.Timeout.Infinite);
    }
    
    void OnSlideChanged(PowerPoint.SlideShowWindow Wn)
    {
        PowerPoint.SlideShowView view = this.Application.SlideShowWindows[1].View;
        int slideNumber = view.CurrentShowPosition;
        // rest of the code
    }

    Therefore, my question is : is there any built-in methods to get the actual or the target next slide when the user navigate next of previous during the presentation show?

    Friday, March 27, 2015 8:11 AM

Answers

  • Hi,

    you can do something like this:

    SlideShowWindows(1).View.Slide.SlideIndex

    or

    SlideShowWindows(1).View.Slide.SlideNumber

    This will return the current slide index. So to get the next one you can sum + 1 to it right?

    More details here: 

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members(v=office.14).aspx

    Best regards.


    Friday, March 27, 2015 8:20 AM