|
-
Feb 17th, 2004, 11:57 AM
#1
Thread Starter
Member
Passwording a Macro
How do I assign a password to a macro? I.e. before you run the macro you must enter a password.
Is it difficult to manage/change/update etc?
Many Thanks
-
Feb 17th, 2004, 02:27 PM
#2
Junior Member
This is very easy
Just create a variable called strPassword. Assign it a value like "mywords" and then have a message box pop up at the beginning of the macro. If the password they enter does not match your strPassword variable, the macro quits. if not, it runs. Of course, if someone opens your macro to view the code, they will be able to see your password.
Josh
-
Feb 17th, 2004, 02:52 PM
#3
Frenzied Member
Better yet, stay away from macros.
-
Feb 19th, 2004, 10:37 PM
#4
Lively Member
Lock your project with a VBA password so that they cannot can into your code and glance easily at the macro password.
(VBA menu, Under tools, VBA Project Properties, Lock Project for Viewing)
As for the password itself, quite simple.
Dim x as string
x = "password"
display = inputbox("Please enter password")
if display <> x then exit sub
... rest of code
Note, be creative, using password as a password is lame.
As to maintenance, just edit the code and change the value you assign to X.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|