Tech Support Forum banner
Status
Not open for further replies.
1 - 3 of 3 Posts

·
Premium Member
Joined
·
39,538 Posts
LOL...

I asked my question because using code I can disable the closure of Excel and therefore any open workbooks. However, an alternative method of closure is therefore required otherwise you won't be able to close any workbook ever again! The most common way is to put a button on a sheet or other location that can initiate the close.

So, before I provide your closure solution, I'd like to be sure that you are fully aware that you need to arrange a button or alternate means of allowing users to close each workbook they open.

Does that make sense?
 

·
Premium Member
Joined
·
39,538 Posts
LOL!

OK - a quick demo. Open a new workbook and add this code to ThisWorkbook module:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub
Save the workbook with any name and then try and close it with the small x or the large X.
 
1 - 3 of 3 Posts
Status
Not open for further replies.
Top