ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Locking Macros from being edited, but not viewed. (https://www.excelbanter.com/excel-discussion-misc-queries/450052-locking-macros-being-edited-but-not-viewed.html)

Pistolade

Locking Macros from being edited, but not viewed.
 
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

GS[_2_]

Locking Macros from being edited, but not viewed.
 
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



Don Guillett[_2_]

Locking Macros from being edited, but not viewed.
 
On Thursday, May 1, 2014 4:02:42 PM UTC-5, Pistolade wrote:
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







--

Pistolade




All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com