tags:

views:

146

answers:

1

I am using Shared Add-in for office plug-ins.

Can anyone tell me how to handle closing event ( [X] button of my window) programatically in Office COM Add-ins for POWER POINT.

Thanks in advance

A: 

Since Shared Add-ins implement the IDTExtensibility2 interface, you should have implemented the OnBeginShutdown and OnDisconnection methods. OnDisconnection will be called whenever your add-in is unloaded, OnBeginShutdown will be called when the host application, i.e. PowerPoint in your case, is about to be closed:

/// <summary>
///      Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
///      Receives notification that the host application is being unloaded.
/// </summary>
/// <param term='custom'>
///      Array of parameters that are host application specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public virtual void OnBeginShutdown(ref System.Array custom)
{
     // do clean-up when PowerPoint exits.
}

Note that you rather might consider the unload event of the add-in than the shutdown event of the host, as the unload event is where any clean-up for your add-in should happen.

0xA3