Presentation Close event is incorrectly fired while issuing Presentation Print Command


When the print command of a PowerPoint Presentation is issued, the presentation.close event is fired in addition to the Print event・ 

However, the expected behavior is that the presentation.close event should not get fired when the print command is issued.



This is a known issue with PowerPoint 2003/ 2007.



Either of the solutions mentioned below can be used to work around this issue:


This solution exploits the fact that there is a temporary presentation created for the purpose of background printing and temporary presentations are not added to the list of open presentations.

So the workaround is to go through the list of presentations and if current presentation is not found there, then it is the temporary print presentation. The Close Event Handler would ignore the event in that case.

The sample code (c#) to implement the workaround is given below:

   1:  void applicationObject_PresentationPrint(Microsoft.Office.Interop.PowerPoint.PresentationPres)
   2:  { 
   3:      MessageBox.Show("applicationObject_PresentationPrint"); 
   4:  }
   6:  void applicationObject_PresentationClose(Microsoft.Office.Interop.PowerPoint.PresentationPres)
   7:  {
   8:      if (!IsPrintPres(Pres))
   9:      {
  10:          //Write your code for presentation close event here. It will get executed only when a presentation is being closed.
  11:          MessageBox.Show("applicationObject_PresentationClose");
  12:      }
  13:  }
  15:  private bool IsPrintPres(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
  16:  {
  17:      foreach (Microsoft.Office.Interop.PowerPoint.Presentation p in applicationObject.Presentations)
  18:      {
  19:          if (p == Pres)
  20:          {
  21:              return false;
  22:          }
  23:      }
  24:      return true; 
  25:  }


Explicitly set the background print option to false (either programmatically or manually). The sample code(C#) to programmatically set the background print option to false is given below:

   1:  void applicationObject_AfterPresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
   2:  {
   3:      MessageBox.Show("applicationObject_AfterPresentationOpen");
   4:      Pres.PrintOptions.PrintInBackground = MsoTriState.msoFalse;
   5:  }
   7:  void applicationObject_AfterNewPresentation(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
   8:  {
   9:      MessageBox.Show("applicationObject_AfterNewPresentation");
  10:      Pres.PrintOptions.PrintInBackground = MsoTriState.msoFalse;
  11:  }

Comments (0)

Skip to main content