Sep 30 2023 04:04 AM
hi all, I have a workbook loaded with formulas that I don't want to have available if the vba code behind them isn't operational
does anyone know a way to secure excel when vba is not running due to macros being disabled?
Sep 30 2023 05:59 AM
To prevent an Excel workbook from opening or functioning properly when macros are disabled, you can implement the following security measures:
Vba code:
Sub Workbook_Open()
If Application.AutomationSecurity = msoAutomationSecurityLow Then
MsgBox "Macros are disabled. Enable macros to use this workbook.", vbExclamation
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
This code checks the Application.AutomationSecurity property to see if macros are enabled. If not, it displays a message and closes the workbook without saving any changes.
Remember that while these measures can help protect your workbook's content, determined users may still find ways to access the data. Therefore, it is essential to strike a balance between security and usability based on your specific needs and the level of protection required for your Excel workbook. The text and steps were edited with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark them as helpful and like it!
This will help all forum participants.
Sep 30 2023 02:53 PM
Sep 30 2023 03:10 PM
You can't prevent the workbook from being opened if macros are disabled, but you can do the following:
As a result, only the new sheet will be visible if macros are disabled.
Warning: knowledgeable users will be able to circumvent this, but it should be sufficient to protect against accidental misuse.
Oct 01 2023 03:12 PM