Locking Macros from being edited, but not viewed.

P

Pistolade

The idea is to lock a macro so it cannot be changed, but can still b
viewed. Some of the higher-ups don't appreciate my protection.
Thanks,
-Pistolade
 
G

GS

The idea is to lock a macro so it cannot be changed, but can still be
viewed. Some of the higher-ups don't appreciate my protection.
Thanks,
-Pistolade-

Unfortunately Excel's VBProject protection scheme isn't that granular.
If users can see it then they can also modify it!

What I do for myself is my projects disable any/all ways to access the
VBE and build a mechanism into them that enables me 'developer' access
to the VBE based on a specific file being located in the same path as
the Excel file. This file contains encrypted project-specific info so
it can't be copied/used with other projects. My projects use this to
configure UI settings at startup so they know which built-in menus and
keyboard shortcuts to disable for normal users.

This might be a more complex solution than you're looking for, though!

Another approach is to 'hook' all UI actions that target access to the
VBE to require a username:password login to enable. As stated earlier,
though, this will allow viewing/modifying unlocked projects.

Finally, you could implement a mechanism that prints or displays your
code based on user login. This involves getting the 'Current User' via
something like...

If InStr(1, sAllowedUsers, Environ("username")) > 0 Then
'print or display the code
End If

...which you can manage via a simple button (or menuitem if your project
creates its own menus/toolbar).

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
D

Don Guillett

The idea is to lock a macro so it cannot be changed, but can still be

viewed. Some of the higher-ups don't appreciate my protection.

Thanks,

-Pistolade-
You could just copy the code to a worksheet for viewing.. You could even protect the sheet so they couldn't even change there. Or, let them change for you to change the real code accoringly
 

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