View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Checking for security level to allow macros to run

Hi Klaus,

The only way to know if macros are enabled or not is to try it. If your
code is running, there is no point in checking the security level, as you
know macros are enabled. If macros are disabled, then there is no code in
the world that will work, as it will never run.

Ron's advice is sound, and is often used to "lock down" a workbook.
Basically, you lock down your workbook with protection, hiding the relevant
worksheets/etc. In the Workbook_Open event, you show all the sheets and run
whatever code you need to run in order to allow for user interaction. If
macros are disabled, your code will not be triggered, and all the user will
be left with is a message on the worksheet that he/she must enable macros in
order to use the workbook.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Klaus wrote:
I'm not sure how I can use this technique to check for the security
level. Klaus

"Ron de Bruin" wrote:

Hi Klaus

You can hide all sheets exept one
On that sheet you put a messege like "you must eneble macro's to
work with this workbook"

Then in the workbook open event unhide the sheets and in the before
save event hide them


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Klaus" wrote in message
...
Is there any way to check programmatically, if the security level
is set to allow macros to run, and then 1) display a message
indicating that the security level must be set to medium and/or the
macros must be enabled; and 2) stop any activity on the workbook
and force the user to restart excel with macros enabled?