make sure macro be loaded without user intervention

  • Thread starter Thread starter Soe
  • Start date Start date
S

Soe

i hv a code which protects selected columns according to users' login name,
so that unautorized user can't edit on columns on which he is not supposed
to.
there is a problem, user has to "enable" macro when he opens the workbook.
If he disable the macro, then the whole protection dies as there is no macro
to run to check login name and authorization.
anybody can advice?
 
Soe,

Why not try defaulting the columns to protected and having
the macro UNprotect the columns. That way, if the user
disables the macro, he cannot disable the protection.

Regards,
Ryan
 
Maybe you can make the file read-only with a note that
macros must be enabled to write to the sheet. When the
macro is initiated, it can disable read only then protect
the columns.

Another way is to have the file on your computer so other
users have to network the file for access.

Or if there is only one computer, use Administration
rights to adjust the settings in the toolbars. Remove the
enable/disable macro toolbar setting altogether so it is
not present. This way there is no option.



There is a way to do what you want but it is a secret and
I don't know what it is.
 
You can do a couple of things:
1) set the Tools|Macro|Security... menu option in Excel
to Low (this will enable the running of macros ALL the
time - careful though, since this will run malicious
macros from nefarious sources as well). You could also
digitally sign your macro, which I believe will allow you
to change the security level to Medium.
2) In a VBA module, create a macro called "Sub
Auto_Open". Excel will automatically execute all code
within the Auto_open subroutine whenever the file is
opened. You can program within the Auto_open routine,
code that looks at the users login name by using
the "Application.UserName" function, which will give the
name of the current user. From there restrict who has
access to what. Also look up "UserAccessList" and
UserAccess Object" from within the Visual Basic Help
structure within Excel. To get to the VBA portion from
Excel, press the [Alt] + [F11] keys simultaneously.

Andrew Lenczycki
 
Back
Top