Reputation: 11
In my ThisAddins.cs am having WorkbookBookBeforeClose Event and am having one button event in Ribbon.cs file in that i written workbook.close (true,workbook.fullname,null) it is not firing the WorkbookBookBeforeClose Event while working with Multiple file.
Is there anything having to follow for calling workbookBeforeClose Event?
Upvotes: 0
Views: 111
Reputation: 49397
The following code works fine on my side:
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WorkbookBeforeClose += ApplicationOnWorkbookBeforeClose;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
// Catch the before close event
private void ApplicationOnWorkbookBeforeClose(Excel.Workbook wb, ref bool cancel)
{
MessageBox.Show("ApplicationOnWorkbookBeforeClose");
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
Upvotes: 1