To unprotect password-protected sheet by Macro?

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
 
D

Don Guillett

try


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

jeff

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
 

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

Top