Force "Enable" Macros on Userform

T

TotallyConfused

I have a Userform that I would like to have users force to "enable macros".
Do not want to give them an option to "disable macros". Can this be done?
If so how? Thank you very much.
 
P

Patrick Molloy

no. enabling macros is a security issue. yo cannot use code to override this.
If you could m then spammers and malware would be able to. that would be a
BAD thing.

Also, if code is not enabled, you wouldn't be able to launch the th
userform. and if its disabled, what happens to the code that running to
generate the userform?
 
S

Sam Wilson

Nope.

All you can really do is make the relevant sheets etc very invisible, lock
your VB project and have code to unhide the sheets. This way if the user
enables macros they'll see they're fine, if they don't then they can't use
your workbook.

Sam
 
T

TotallyConfused

Thank you for your responses. For the part users will not want to mess with
the form. However, there is alway a wise guy. Just want to be able to
protect form and wise guys from changing any code. How do I lock up my VB
project? My worksheets are already hidden but not with code. How do I do
that? Thank you all for your help. Very much appreciated.
 
S

Sam Wilson

In the VB window, highlight the relevant sheet in the project explorer, and
in the properties window set "Visible" to "-2 - xlSheetVeryHidden"

Once you've done this, right click your project and go to
VBAProjectProperties, and protection and tick "Lock project for viewing" -
put a password in but definitely don't forget it - if you do then it's
virtually impossible to recover.

You then need to create a workbook open event which does something along the
lines of

dim ws as worksheet
for each ws in worksheets
ws.visible = xlsheetvisible
next ws

and a workbook before close event:

dim ws as worksheet
for each ws in worksheets
ws.visible = xlsheetveryhidden
next ws
 
D

Dave Peterson

Inside the VBE.
select your workbook's project
tools|vbaproject properties|protection tab

Save, close and reopen your workbook to see how it works.
 

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