PDA

View Full Version : Solved: Set the Excel Security level through code



tstav
02-23-2008, 01:14 AM
Is there a way to automatically set Excel Security level to Medium, right before opening a specific workbook (which contains VB code) ?

The problem is that I have set up a VBA Application (say Book1.xls) which a number of users are going to use.
Some users have set the Excel Security level on their PCs to Low, and so, when they open the Workbook the VB code does not get activated.

Bob Phillips
02-23-2008, 02:06 AM
If they have the workbook set to low, the VBA is activated without any question . It is high whereby the VBA dsoes not get activated, and that is because the user has chosen to. If you could change that, an already feeble security system woul;d be wide open.


The standard way to approach this is as follows.
- create a worksheet with a message on explaining that for this workbook to run it needs macros enabled, maybe even a few screenshots
- hide all other worksheets
- add some code in the Workbook_Open event that un hides the other sheets, but hides that sheet.

What happens is that if they do not enable macros, they will only see the
warning sheet, telling them how to do it. If they enable macros,it will
startup the workbook as it should be.

tstav
02-23-2008, 02:26 AM
Hi Xld, and thank you very much for the prompt reply.
You are correct for the Low Security level always allowing VBA to run, sorry for my mixup. It is the High setting that causes the trouble...

Quote: "If you could change that, an already feeble security system would be wide open"
This is exactly the very answer I was anticipating ... but I said to myself "don't loose hope, someone may have come up with a snicky way of doing it...".

Thank you very much for the idea of showing a WorkSheet with the appropriate message in case Code has not been activated.
You've been great!

By the way, how come Location is UK and Country is Chile in your profile??
Best regards, tstav

Bob Phillips
02-23-2008, 03:09 AM
By the way, how come Location is UK and Country is Chile in your profile??

That is all historical. When I joined VBAX I was in Chile at the time, so I used the Chilean flag, and I have never c hanged it even though I am back. I kinda like it :)

tstav
02-23-2008, 03:20 AM
Thanks for telling me. Nice talking to you. Have a good day.

Bob Phillips
02-23-2008, 03:22 AM
It's always a pleasure. Where in Greece are you, an island or the mainland?

tstav
02-23-2008, 03:44 AM
Where in Greece are you, an island or the mainland?
Mainland, about 10 kilometers from Athens.
London is the only city of UK that I 've visited thanks to various Seminars/Lectures on IS Audit stuff (I was an IS Auditor for about 8 years). Seminars were boring but I liked London. :-)

Bob Phillips
02-23-2008, 04:04 AM
Yeah, I like London too, visit as often as I can, even though it is very nice where I live.

I have been to a few Grek islands, but never been to the mainland. We are looking at going to the Pelion later this year, would you recommend it?

tstav
02-23-2008, 05:04 AM
Nihil simul inventum est et perfectum
Your moto caught my attention and since its Latin words "sounded" to me like:
<Nothing Simultaneously Invented Is And Perfected> (which already made enough sense),
I also looked it up and found the English:
<Nothing is invented and perfected at the same time>.
I like it xld!

By the way, Pelion is among the most beautiful and thus most visited places in Greece. I'm sure you will have a good time.