Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel-password protect sheet w\o causing macro failure...

Status
Not open for further replies.

Acquaman

Technical User
Feb 14, 2003
21
US
Thank you for taking the time to help.

I would like to password protect the sheets in an application that I have made but, this causes the macro code to fail at:
ActiveSheet.Unprotect
Is there a way to put the password in the code so that the code can continue to be executed? Presently, I have made it hard for someone to unprotect the sheets manually by replacing the menu with my own and blocking key stokes, etc. But, I am still afraid of someone getting around those measures.

Your help is greatly appreciated.
Thanks again.
Acquaman
 
Just put the password (either directly in quotes, or stored in a variable) directly after the unprotect command, seperated by a space:
Code:
Sheets("MySheetName").Unprotect PasswordVar
' OR
Sheets("MySheetName").Unprotect "MyPassword"
Let me know if that's what you are after!

VBAjedi [swords]
 
Hey Mr. Jedi!
You guys never cease to amaze me with how quickly you respond! I hope you know how much all us little guys appreciate it.

That does look like it will do the trick. Nice and simple too. Is there a FIND\REPLACE in the VBE to run through all my code and do the typing for me or am I getting carried away now?

I am off to try it...........
Thanks Again!
Acquaman
 
Yeah, there is Find/Replace under the Edit menu in the VBE.

Glad to help!

VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top