Example #1
0
        public static StringBuilder Start(string filePath)
        {
            StringBuilder stringBuilder = new StringBuilder();

            PowerPoint.Application   powerApplication = new PowerPoint.Application();
            PowerPoint.Presentations pptPresentations = powerApplication.Presentations;

            PowerPoint.Presentation pptPresentation = pptPresentations.Open(filePath,
                                                                            MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

            PowerPoint.Slides pptSlides = pptPresentation.Slides;

            if (pptSlides != null)
            {
                //var slidesCount = pptSlides.Count;

                foreach (PowerPoint.Slide slide in pptSlides)
                {
                    foreach (PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == MsoTriState.msoTrue && shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            PowerPoint.TextRange range = shape.TextFrame.TextRange;
                            if (range != null && range.Length > 0)
                            {
                                stringBuilder.Append(" " + range.Text);
                            }
                        }
                    }
                }
            }
            return(stringBuilder);
        }
Example #2
0
        /**
         * private utils
         **/
        #region privateUtils
        private List <PowerPoint.Slide> ToSlideList(PowerPoint.Slides slides)
        {
            List <PowerPoint.Slide> list = new List <PowerPoint.Slide>();

            foreach (PowerPoint.Slide slide in slides)
            {
                list.Add(slide);
            }
            return(list);
        }
        private void getPPtData()
        {
            try
            {
                if (pptApplication != null)
                {
                    // Get Presentation Object
                    presentation = pptApplication.ActivePresentation;
                    // Get Slide collection object
                    slides = presentation.Slides;
                    // Get Slide count
                    slidescount = slides.Count;

                    // Get current selected slide
                    try
                    {
                        // Get selected slide object in normal view
                        slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                    }
                    catch
                    {
                        // Get selected slide object in reading view
                        slide = pptApplication.SlideShowWindows[1].View.Slide;

                    }
                }
            }
            catch
            {

                // if pptApplication.SlideShowWindows[1].View.Slide is invalid,
                // e.g. the 'Press any key to exit slideshow' screen
                // ignore.

            }
        }