ExcelBanter

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

rbanks[_8_]

protect a macro
 

I've got a workbook that email out to about 50 people each month.
have a "homepage" where I've inserted several Macro buttons an
hyperlinks.

Some of the macros, I only want available to 3 or 4 people. Can I mak
those macros where it prompts you for a password if you try to ru
them?

If so, how do I assign the password?

Thank

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com


Chip Pearson[_2_]

protect a macro
 
There isn't any built in way to password protect the execution of a macro --
you have to write the code to prompt for a password. For example,

Sub TheMacro()
If InputBox("Enter a password:") < "the_password" Then
Exit Sub
End If
'
' rest of code
'
End Sub


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



"rbanks" wrote in message
...

I've got a workbook that email out to about 50 people each month. I
have a "homepage" where I've inserted several Macro buttons and
hyperlinks.

Some of the macros, I only want available to 3 or 4 people. Can I make
those macros where it prompts you for a password if you try to run
them?

If so, how do I assign the password?

Thanks


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/




Gord Dibben

protect a macro
 
rbanks

Sub pass()
enterpass = InputBox("Enter Password To Run Macro")
If enterpass < "rbanks" Then GoTo notright
MsgBox "You have got it right"
Exit Sub
notright:
MsgBox "Incorrect Password Try Again"
End Sub

Be sure to set Protection on your VBA Project so's others can't see your macro
password.

Note: there are Password crackers out there that can break the password on
your VBA Project. Excel is not secure from those who would wish to snoop but
you can keep out the casual and not-so-snoopy users.

Gord Dibben XL2002

On Fri, 21 Nov 2003 14:18:52 -0600, rbanks
wrote:


I've got a workbook that email out to about 50 people each month. I
have a "homepage" where I've inserted several Macro buttons and
hyperlinks.

Some of the macros, I only want available to 3 or 4 people. Can I make
those macros where it prompts you for a password if you try to run
them?

If so, how do I assign the password?

Thanks


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/




All times are GMT +1. The time now is 01:17 PM.

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