Workbook_BeforeClose event is not canceled

  • Thread starter Mircea Pleteriu
  • Start date
M

Mircea Pleteriu

Hi,

I'm developing an Office COM Add-in by using Visual C# .NET.

The purpose of the add-in is to prevent any open workbook to get closed.
To achieve this I've implemented the following handler for the
Workbook_BeforeClose event of the Excel.Application object.

private void Connect_WorkbookBeforeClose(Excel.Workbook Wb, ref bool Cancel)
{
System.Windows.Forms.MessageBox.Show("It's not allowed closing the
workbook!");
Cancel = true;
}

At runtime, closing a workbook it pops up the message AND CLOSES the
workbook. The even is not canceled.

Am I missing anything?

Thanks,
Mircea
 
P

Peter Huang [MSFT]

Hi

This is an known issue, and it has been fixed in office 2003, I have
verified it on my side.
Here is a link for your reference.
BUG: Cancel parameter for Office events is ignored in Visual Studio .NET
2003 (830519)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;830519

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top