' using events in PowerPoint
' taken from Example06.vb

Private Sub Example06Main()

   ' start powerpoint and turn off msg boxes
   Dim powerApplication As New PowerPoint.Application()
   powerApplication.Visible = MsoTriState.msoTrue

   ' PowerPoint 2000 doesnt support DisplayAlerts, 
' we check at runtime its available and set
If (powerApplication.EntityIsAvailable("DisplayAlerts")) Then powerApplication.DisplayAlerts = PpAlertLevel.ppAlertsNone End If ' we register some events. note: the event trigger was called from power point, ' means an other Thread
Dim newCloseHandler As PowerPoint.Application_PresentationCloseEventHandler = _
AddressOf Me.powerApplication_PresentationCloseEvent AddHandler powerApplication.PresentationCloseEvent, newCloseHandler Dim newAfterNewHandler As PowerPoint.Application_AfterNewPresentationEventHandler = _
AddressOf Me.powerApplication_AfterNewPresentationEvent AddHandler powerApplication.AfterNewPresentationEvent, newAfterNewHandler ' add a new presentation with one new slide Dim presentation As PowerPoint.Presentation = _
powerApplication.Presentations.Add(MsoTriState.msoTrue) Dim slide As PowerPoint.Slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank) ' close the document presentation.Close() ' close power point and dispose reference powerApplication.Quit() powerApplication.Dispose() End Sub Private Sub powerApplication_PresentationCloseEvent(ByVal Pres As NetOffice.PowerPointApi.Presentation) textBoxEvents.BeginInvoke(_updateDelegate, _
New Object() {"Event PresentationClose called."}) Pres.Dispose() End Sub Private Sub powerApplication_AfterNewPresentationEvent(ByVal Pres As NetOffice.PowerPointApi.Presentation) textBoxEvents.BeginInvoke(_updateDelegate, _
New Object() {"Event AfterNewPresentation called."}) Pres.Dispose() End Sub Private Sub UpdateTextbox(ByVal message As String) textBoxEvents.AppendText(message & vbNewLine) End Sub

Last edited Jun 13, 2012 at 2:13 PM by SebastianDotNet, version 5

Comments

No comments yet.