ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet close event++? (https://www.excelbanter.com/excel-programming/327322-worksheet-close-event.html)

has ex

Worksheet close event++?
 
Thanks for the reply,
I have an out of proc application (automating Excel with C++ client)
that holds references to many ranges. If user deletes one of the worksheets
that I have a reference, then I need to clear my pointers. I am able to do
this if the user deletes the workbook, because I get an event on the close,
but not if he deletes a single worksheet.
Many thanks

Has



Peter T

Worksheet close event++?
 
Normally the sheet is active when user manually deletes it. After it's
deleted a Sheet Activate event will fire, both at Workbook and Application
levels.

Either directly in, or called from this event you can check your sheet still
exists, eg

Dim ws as worksheet
On error Resume Next
Set ws = MyGlobalRange.Parent
If Err.number then
Set MyGlobalRange = Nothing
'etc
End if

Regards,
Peter T

"has ex" wrote in message
...
Thanks for the reply,
I have an out of proc application (automating Excel with C++ client)
that holds references to many ranges. If user deletes one of the

worksheets
that I have a reference, then I need to clear my pointers. I am able to do
this if the user deletes the workbook, because I get an event on the

close,
but not if he deletes a single worksheet.
Many thanks

Has






All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com