Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lock macro from users

Status
Not open for further replies.

venkman

Programmer
Oct 9, 2001
467
US
I'd like to lock the macro code in a workbook (preventing users from changing or possibly viewing the macro code), but allow people to change the data on the sheets contained within the workbook. How do I do this? It does not need to be really secure, just annoying enough to discourage users from editing the macros. I have no desire to prevent the highly-motivated.

-Venkman
 
Depending upon what you are doing with your macros, you can hide them from the users entirely by passing a parm to the macro. For example Sub Macro1() will show up in the Tools, Macro list. But if you change it to Sub Macro1(pvarDummy As Variant) it will NOT show up in the list at all because you can't pass paramaters to macros.

Obviously, this approach will only work if you can fire the macros from events automatically. There may be other ways as well.

Good LucK!

 
You can protect your VBA code from being viewed or edited.

From the VB editor menus select Tools, VBAProject Properties and select the Protection tab. Then check Lock project for Viewing and enter a password (and confirm).

Save the workbook, close it and re-open and you should find that you cannot edit the code unless you have a password.

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top