Example #1
0
        public static void GoToSlide(PowerPoint.View view, string slideNumberString)
        {
            int slideNumber;

            if (Int32.TryParse(slideNumberString, out slideNumber))
            {
                try
                {
                    view.GotoSlide(slideNumber);
                }
                catch (Exception)
                {
                    System.Windows.Forms.MessageBox.Show(String.Format("Could not load slide number {0}.\nTry again.", slideNumber));
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Could not parse number.\nTry again.");
            }
        }
        public void gotoSlide(int addcount)
        {
            try
            {
                if (Globals.ThisAddIn.Application.ActiveWindow.Active == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.View         view         = Globals.ThisAddIn.Application.ActiveWindow.View;
                    PowerPoint.Presentation presentation = Globals.ThisAddIn.Application.ActivePresentation;
                    PowerPoint.Slide        slide        = (PowerPoint.Slide)view.Slide;
                    if (slide.SlideIndex + addcount > 0 && addcount <= presentation.Slides.Count)
                    {
                        view.GotoSlide(slide.SlideIndex + addcount);
                    }
                }
            }
            catch (Exception)
            {
                // throw;
            }

            try
            {
                if (Globals.ThisAddIn.Application.ActivePresentation.SlideShowWindow.Active == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.SlideShowView view         = Globals.ThisAddIn.Application.ActivePresentation.SlideShowWindow.View;
                    PowerPoint.Presentation  presentation = Globals.ThisAddIn.Application.ActivePresentation;
                    PowerPoint.Slide         slide        = (PowerPoint.Slide)view.Slide;
                    if (slide.SlideIndex + addcount > 0 && addcount <= presentation.Slides.Count)
                    {
                        view.GotoSlide(slide.SlideIndex + addcount);
                    }
                }
            }
            catch (Exception)
            {
                // throw;
            }
        }