To unprotect password-protected sheet by Macro?

  • Thread starter Thread starter Lana
  • Start date Start date
L

Lana

Hi all

This is the problem:
my boss wants all the cells to be protected and formulas invisible
I've got macroses in this sheet. In order to execute the macro,
included "Activesheet.Unprotect" in the beginning of each macro. Whe
the password is set, Excel prompts for the password upon the executio
of this code. End users ain't supposed to know the password.

*Is there any way to Unprotect the password protected worksheet and t
automatically password-protect it back when the macro finished workin
WITHOUT PROMPTING FOR THE PASSWORD?*

Thanks a lot
 
try


activesheet.unprotect:password="mypassowrd"
yourcode
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
Password:="MyPassword"
 
Hi, Lana,

Sure you can do it, but are you sure you want to?
You either have to embed the password in your macro
code or somewhere else.

Sub passwd()
ActiveSheet.Unprotect "MyPsswd"
MsgBox "unprotected"
ActiveSheet.Protect "MyPsswd"
MsgBox "Protected Again"
End Sub

jeff
 
Back
Top