![]() |
Hide the close X in excel
Hi,
I have a code, (below), to hide toolbars and to prevent users from tampering. I have a macro which performs some operations and then saves and closes the file. I have just realised that the X to close excel on the top right corner is still visible meaning the file can be closed without using the macro. Is it possible to also hide this feature so users must close using the macro? Thanks Private mFormulaBar Private Sub Workbook_BeforeClose() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = True Next oCB Application.DisplayFormulaBar = mFormulaBar End Sub Private Sub Workbook_Open() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = False Next oCB mFormulaBar = Application.DisplayFormulaBar Application.DisplayFormulaBar = False End Sub |
Hide the close X in excel
Hi
Too much alteration of the excel interface will annoy your users more than it is worth. If your users have more than one excel file open, for example, any code will probably stop them closing those files as well as yours, even if they are not saving your file. Try putting your macro code that runs when excel closes into your before_close macro, so that it runs automatically. regards Paul On Apr 22, 3:04*pm, LiAD wrote: Hi, I have a code, (below), to hide toolbars and to prevent users from tampering. *I have a macro which performs some operations and then saves and closes the file. *I have just realised that the X to close excel on the top right corner is still visible meaning the file can be closed without using the macro. *Is it possible to also hide this feature so users must close using the macro? Thanks Private mFormulaBar Private Sub Workbook_BeforeClose() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = True Next oCB Application.DisplayFormulaBar = mFormulaBar End Sub Private Sub Workbook_Open() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = False Next oCB mFormulaBar = Application.DisplayFormulaBar Application.DisplayFormulaBar = False End Sub |
Hide the close X in excel
How come your Workbook_BeforeClose event header does not have a "Cancel"
argument? Is the one you posted your own creation or was it provided by the VB interface? If VB provided it, what version of Excel are you using? On my XL2003 system, the BeforeClose event comes with the Cancel argument allowing you to stop the user requested shut down of the workbook. -- Rick (MVP - Excel) "LiAD" wrote in message ... Hi, I have a code, (below), to hide toolbars and to prevent users from tampering. I have a macro which performs some operations and then saves and closes the file. I have just realised that the X to close excel on the top right corner is still visible meaning the file can be closed without using the macro. Is it possible to also hide this feature so users must close using the macro? Thanks Private mFormulaBar Private Sub Workbook_BeforeClose() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = True Next oCB Application.DisplayFormulaBar = mFormulaBar End Sub Private Sub Workbook_Open() Dim oCB As CommandBar For Each oCB In Application.CommandBars oCB.Enabled = False Next oCB mFormulaBar = Application.DisplayFormulaBar Application.DisplayFormulaBar = False End Sub |
All times are GMT +1. The time now is 01:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com