private void buttonStartExample_Click(object sender, EventArgs e) { // start powerpoint and turn off msg boxes PowerPoint.Application powerApplication = new PowerPoint.Application(); powerApplication.Visible = MsoTriState.msoTrue; // PowerPoint 2000 doesnt support DisplayAlerts, we check at runtime its available and set if (powerApplication.EntityIsAvailable("DisplayAlerts")) { powerApplication.DisplayAlerts = PpAlertLevel.ppAlertsNone; } // we register some events. note: the event trigger was called from power point, means an other Thread powerApplication.PresentationCloseEvent += new NetOffice.PowerPointApi.Application_PresentationCloseEventHandler(powerApplication_PresentationCloseEvent); powerApplication.AfterNewPresentationEvent += new NetOffice.PowerPointApi.Application_AfterNewPresentationEventHandler(powerApplication_AfterNewPresentationEvent); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // close the document presentation.Close(); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); }
private void buttonStartExample_Click(object sender, EventArgs e) { // start powerpoint and turn off msg boxes PowerPoint.Application powerApplication = new PowerPoint.Application(); powerApplication.Visible = MsoTriState.msoTrue; // PowerPoint 2000 doesnt support DisplayAlerts, we check at runtime its available and set if(powerApplication.EntityIsAvailable("DisplayAlerts")) powerApplication.DisplayAlerts = PpAlertLevel.ppAlertsNone; // we register some events. note: the event trigger was called from power point, means an other Thread powerApplication.PresentationCloseEvent += new NetOffice.PowerPointApi.Application_PresentationCloseEventHandler(powerApplication_PresentationCloseEvent); powerApplication.AfterNewPresentationEvent += new NetOffice.PowerPointApi.Application_AfterNewPresentationEventHandler(powerApplication_AfterNewPresentationEvent); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // close the document presentation.Close(); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); }
public TestResult DoTest() { PowerPoint.Application application = null; DateTime startTime = DateTime.Now; try { application = new PowerPoint.Application(); application.Visible = MsoTriState.msoTrue; // PowerPoint 2000 doesnt support DisplayAlerts, we check at runtime its available and set if (application.EntityIsAvailable("DisplayAlerts")) { application.DisplayAlerts = PpAlertLevel.ppAlertsNone; } application.PresentationCloseEvent += new NetOffice.PowerPointApi.Application_PresentationCloseEventHandler(powerApplication_PresentationCloseEvent); application.AfterNewPresentationEvent += new NetOffice.PowerPointApi.Application_AfterNewPresentationEventHandler(powerApplication_AfterNewPresentationEvent); // add a new presentation with one new slide PowerPoint.Presentation presentation = application.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); System.Threading.Thread.Sleep(2000); // close the document presentation.Close(); if (_afterNewPresentation && _presentationClose) { return(new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "")); } else { return(new TestResult(false, DateTime.Now.Subtract(startTime), String.Format("AfterNewPresentation:{0} , PresentationClose:{1}", _afterNewPresentation, _presentationClose), null, "")); } } catch (Exception exception) { return(new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "")); } finally { if (null != application) { application.Quit(); application.Dispose(); } } }
public TestResult DoTest() { PowerPoint.Application application = null; DateTime startTime = DateTime.Now; try { application = new PowerPoint.Application(); application.Visible = MsoTriState.msoTrue; // PowerPoint 2000 doesnt support DisplayAlerts, we check at runtime its available and set if (application.EntityIsAvailable("DisplayAlerts")) application.DisplayAlerts = PpAlertLevel.ppAlertsNone; application.PresentationCloseEvent += new NetOffice.PowerPointApi.Application_PresentationCloseEventHandler(powerApplication_PresentationCloseEvent); application.AfterNewPresentationEvent += new NetOffice.PowerPointApi.Application_AfterNewPresentationEventHandler(powerApplication_AfterNewPresentationEvent); // add a new presentation with one new slide PowerPoint.Presentation presentation = application.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); System.Threading.Thread.Sleep(2000); // close the document presentation.Close(); if(_afterNewPresentation && _presentationClose) return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, ""); else return new TestResult(false, DateTime.Now.Subtract(startTime), String.Format("AfterNewPresentation:{0} , PresentationClose:{1}", _afterNewPresentation, _presentationClose), null, ""); } catch (Exception exception) { return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, ""); } finally { if (null != application) { application.Quit(); application.Dispose(); } } }