ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect a Macro (https://www.excelbanter.com/excel-programming/360963-protect-macro.html)

Darin Kramer

Protect a Macro
 


Howdie All,

I have a workbook with many macros in, some I use for design, and would
not like users to be able to run them, (which they can currently easily
do by selecting Tools...macro...run...)

So the question is, can I protect some macros from being run?

Regards

D

*** Sent via Developersdex http://www.developersdex.com ***

Zone

Protect a Macro
 
You can use the Private keyword with your macro to prevent it from
showing in the list of macros, such as

Private Sub Macro1()


Brian Matlack[_73_]

Protect a Macro
 

Darin:
This will prevent the user from accessing the macro from the Tools
menu.

Sub macro1_(Optional_HideRoutine_As_Integer)_

Brian M.


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=540314


Ivan Raiminius

Protect a Macro
 
Hi Darin,

you can also use useless optional parameter:

Sub macro1(optional useless as variant)

macro1 will not be visible to the user in macrorun, but you will not
have any problems in your code with this useless parameter (maybe you
could have problems with making the sub private).

Regards,
Ivan


Chip Pearson

Protect a Macro
 
If you put

Option Private Module

as the first line of code in your code module, none of the macros
in that module will be listed in the Macro Dialog. If, however,
the user knows the name of the macro, he can type it in the
dialog and get it to run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Darin Kramer" wrote in message
...


Howdie All,

I have a workbook with many macros in, some I use for design,
and would
not like users to be able to run them, (which they can
currently easily
do by selecting Tools...macro...run...)

So the question is, can I protect some macros from being run?

Regards

D

*** Sent via Developersdex http://www.developersdex.com ***




Darin Kramer

Protect a Macro
 
Thanks all for your feedback!!

Regards

Darin



*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 11:17 AM.

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