Excel - Closing a Workbook if Macros aren't enabled.

Asked By SlyMaelstro on 06-Aug-07 02:46 PM
Basically, I want to make my workbook such that either you enable the
macros or it closes the workbook. That means when the prompt comes up
regarding macros, if you choose to disable them it will close the
workbook. Obviously, this can't be done with a macro because the user
has disabled them... so does anyone know a way? The reasoning for this
is that my macros are designed to ensure the user fills in certain
fields and they do it correctly. I'm doing this with macros as I don't
believe Excel offers a method of requiring a cell to be filled in
without them. Any help with this would be great.

-- Bill




Michae replied on 06-Aug-07 03:00 PM
Set up a dialogbox or small form confirming the desire of the user to enable
macros, when your macro really is doing is exiting/closing the workbook if
the user clicks on No or if the user clicks on cancel. You set this tricky
little form on Open and it should provide you with the same results as if you
were enabling macros.
Regards,

Michael Arch.
Please click on yes or no if the positng was helpful
ilia replied on 06-Aug-07 04:06 PM
Here's what I've seen done before.

Set up a worksheet that explains to the user that macros need to be
enabled, and how to enable them.  Make all other sheets xlVeryHidden.
Password your VBA project so that users cannot change this property.
They won't be able to do it from the Immediate window either, if
macros are disabled.

In your Workbook_Open code, call a procedure to unhide the data entry
sheets, and hide the "enable your macros" sheet.  This will only occur
if macros are enabled.  Likewise, insert code to re-hide them in your
Workbook_Close event.

This way, while the workbook won't close by itself with macros
disabled, it will not allow the user to perform data entry either.
Instead, it will instruct the user to close and reopen the workbook,
and enable macros.  If the user screws it up again, this process
repeats.

If the user does enable macros, the Workbook_Open code will setup the
workbook for proper data entry, with all your macros operating as
intended.

Hope this helps your situation.
SlyMaelstro replied on 09-Aug-07 03:00 PM
That's smart. I will do that.

Michael, I do not get your post... how could I get to what you are
saying if Macros are disabled?