LarryG
11-09-2019, 10:16 PM
(FYI this is different than my recent post) If I open two windows on one workbook, such as
Control-N
alt-W-N
then you can close a Window with Control-F4 or Control-W. The workbook is still open but the window closes. So you'd be closing Book1:2 but book1.xls is still open.
I want to Cancel that closing if certain conditions are true. Can I?
The only event that I know of when you close a window is App_WindowDeactivate. However, it doesn't seem to be Cancel-able. Also a problem is that that event happens every time you flip to another window or workbook. I'm only interested in acting on the case where a Window is being closed, such as by Control-F4 or Control-W, but I don't see how to identify that the user has gone (e.g.) Control-F4, as opposed to Control-Tab or something (that's not Closing the window).
All this is for MDI versions of Excel, prior to when they destroyed a lot of VBA code with SDI -- 2013 IIRC.
Control-N
alt-W-N
then you can close a Window with Control-F4 or Control-W. The workbook is still open but the window closes. So you'd be closing Book1:2 but book1.xls is still open.
I want to Cancel that closing if certain conditions are true. Can I?
The only event that I know of when you close a window is App_WindowDeactivate. However, it doesn't seem to be Cancel-able. Also a problem is that that event happens every time you flip to another window or workbook. I'm only interested in acting on the case where a Window is being closed, such as by Control-F4 or Control-W, but I don't see how to identify that the user has gone (e.g.) Control-F4, as opposed to Control-Tab or something (that's not Closing the window).
All this is for MDI versions of Excel, prior to when they destroyed a lot of VBA code with SDI -- 2013 IIRC.