简体   繁体   中英

How to check the presentation end with PowerPoint.Interop

I'm showing a Powerpoint presentation inside a page with ASP.NET and I have only the Next and Previous buttons.

What I would like to check is whether it's the presentation end or not as soon as the user click in Next button.

That's how I'm trying to do this:

private void btnNext_Click(object sender, EventArgs e)
    {
        try
        {

            presesntation.SlideShowWindow.View.Next();
            if (presesntation.SlideShowWindow.View.State.Equals(Microsoft.Office.Interop.PowerPoint.PpSlideShowState.ppSlideShowDone))
            {
                if (this.PresentationEnd != null)
                {
                    this.PresentationEnd(this, EventArgs.Empty);
                }

                btnNext.Visible = false;
                btnPrevious.Visible = false;
                foreach (Process proc2 in Process.GetProcessesByName("POWERPNT"))
                {
                    proc2.Kill();
                }
            }
            ///Cria um delay de 1 seg para o proximo clique no botão
            Thread.Sleep(1000);
        }
        catch
        {

        }
    }

The line that checks the presentation end is if (presesntation.SlideShowWindow.View.State.Equals(Microsoft.Office.Interop.PowerPoint.PpSlideShowState.ppSlideShowDone)) but it doesn't work with some .ppsx presentations. Although it works with every .pps presentation

How do I check the presentation end?

You could have your next click handler check the current slide's Slide.Index to see if it's equal to the presentation Slides.Count. If so, you're already on the last slide (ie, you're at the end of the presentation).

You could then end the show yourself rather than trying to sort out whether the user has ended it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM