private void HighlightWords() { if (_words == null) { return; } PowerPoint.Slides slides = _presentation.Slides; int count = 0; foreach (PowerPoint.Slide slide in slides) { count++; PowerPoint.Shapes shapes = slide.Shapes; foreach (PowerPoint.Shape shape in shapes) { if (shape.HasTextFrame == MsoTriState.msoTrue) { if (cmp.Compare(shape.TextFrame.TextRange.Text, _words [0].Text, CompareOptions.StringSort | CompareOptions.IgnoreCase) == 0) { _presentation.SlideShowWindow.View.GotoSlide(count, MsoTriState.msoTrue); break; } //if ( shape.TextFrame.TextRange.Text.CompareTo() ) //_presentation.SlideShowWindow.View.GotoSlide( count, MsoTriState.msoTrue ); //shape.Select( MsoTriState.msoTrue ); //slide.MoveTo( 1 ); //break; } } } }
private string GetDocumentText(object path) { StringBuilder result = new StringBuilder(); try { InitializePowerPoint(); if (_powerPoint != null) { PowerPoint.Presentation presentation = _powerPoint.Presentations.Open((string)path, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse); PowerPoint.Slides slides = presentation.Slides; int count = slides.Count; foreach (PowerPoint.Slide slide in slides) { PowerPoint.Shapes shapes = slide.Shapes; count = shapes.Count; foreach (PowerPoint.Shape shape in shapes) { if (shape.HasTextFrame == MsoTriState.msoTrue) { result.Append(shape.TextFrame.TextRange.Text).Append(" "); } } //foreach ( PowerPoint.Comment comment in slide.Comments ) //{ //comment.Text; //} } } } catch (Exception exception) { _tracer.TraceException(exception); } ShutdownPowerPoint( ); return(result.ToString()); }
public bool GetOpenPpt() { bool success = false; try { // Get Running PowerPoint Application object pptApplication = Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application; } catch { } if (pptApplication != null) { success = true; // 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; } } return(success); }
}//end constructor for pptcontrol #endregion #region Small Helper Functions /// <summary> /// initPres initializes the current presentation and slide /// </summary> /// <returns>always returns true, showing presentation is initialized</returns> private bool initPres() { pptPres = pptApp.ActivePresentation; presSlides = pptPres.Slides; return(true); }