View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen Stephen Bullen is offline
external usenet poster
 
Posts: 67
Default Cancelling the BeforeClose Event

Hi Onedaywhen,

I tested this on VSTO 2003 and conclude it has not been fixed.


I just downloaded the released version from MSDN and installed it. I
used the following code to test it:

Private Sub ThisWorkbook_BeforeClose(ByRef Cancel As Boolean) _
Handles ThisWorkbook.BeforeClose

MsgBox(ThisWorkbook.Name)
Cancel = (UCase(ThisWorkbook.Name) = "BOOK1.XLS")
End Sub

I found that when I saved the workbook as book1.xls and tried to close
it, it didn't close. When I saved it as book2.xls and tried to close
it, it closed fine. So I conclude that the Cancel property is working
fine in the released code.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk