Protect macro for unauthorised use

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I protect a macro so that you need to give a password before you can
run the macro?
Once the file is closed the macro protection should automatically be
protected.

Thank you in advance!
 
One way is to ask for the password right in the macro.

Sub PassExample()
Dim PW As String
PW = InputBox("Password please", "Password to Run Macro")
If PW = "pass" Then
MsgBox "Running macro"
Else
MsgBox "Sorry"
End If
End Sub


--
Jim
| How can I protect a macro so that you need to give a password before you
can
| run the macro?
| Once the file is closed the macro protection should automatically be
| protected.
|
| Thank you in advance!
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top