Disabling macros with Shift+[OPEN]

B

brian

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.
 
B

Basie

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top