![]() |
Any vba code to disable only close button in Excel workbook, please?
Dear all
Could anyone give me some sample code on disabling the close button in Excel workbook? I tried the Tool - Protect - Check Windows method. But, it will disable the maximize and minimize buttons as well. Moreover, it will minimize the workbook. Please give me some advices. thanks Cheers Bon |
Any vba code to disable only close button in Excel workbook, please?
Hi,
You can use the BeforeClose event of the worrkbook using VBA: Private Sub Workbook_BeforeClose(Cancel As Boolean) If MsgBox("Are you sure", vbQuestion + vbYesNo, "Close the book") = vbNo Then Cancel = True End If End Sub If you use it like this Private Sub Workbook_BeforeClose(Cancel As Boolean) Cancel = True End Sub You will nevere be able to close the workboor or end Excel on a normal way! HTH Executor |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com