ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disabling macros with Shift+[OPEN] (https://www.excelbanter.com/excel-programming/275669-disabling-macros-shift-%5Bopen%5D.html)

Brian

Disabling macros with Shift+[OPEN]
 
Is there a way to prevent a user from disabling VBA macros
by holding SHIFT when clicking the OPEN button?
I'm using Excel 2000.

Thanks,

Brian.

Basie[_2_]

Disabling macros with Shift+[OPEN]
 
I do it as follows:

Name a cell in worksheet "X" as (say) AutoOpenExecuted.
Add a Workbook_Open procedure (you probably have one
already) and, at the end of it, insert

Sheets("X").Range("AutoOpenExecuted").Value = True

Also add a Workbook_BeforeSave procedure and include in it:

Sheets("X").Range("AutoOpenExecuted").value = False

In a frequently-used procedure, such as one you call at
the beginning of other procedures to perform housekeeping
tasks, or the Class_Initialize procedure for a frequently-
used class, insert:

If Sheets("X").Range("AutOpenExecuted") = False then _
MsgBox "Don't hold shift key when opening workbook"
Thisworkbook.Close SaveChanges:=False

The trick is to find the right place (or places) to check
if the cell is True or False.


-----Original Message-----
Is there a way to prevent a user from disabling VBA

macros
by holding SHIFT when clicking the OPEN button?
I'm using Excel 2000.

Thanks,

Brian.
.



All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com