Protect w/ passwords in Macro


Posted by Mark on December 02, 2001 7:23 PM

How do I use passwords for sheet protection in macros? I want to protect and unprotect sheets in macros but when I put password protection on a sheet I have to type in the macro even during macro execution. How do I avoid this during the running of a macro?

Thanks -



Posted by Bariloche on December 02, 2001 8:06 PM

Mark,

The syntax is:

Sheets("Sheet1").Protect ("mypassword")

Sheets("Sheet1").Unprotect ("mypassword")

I suggest that you debug your code thoroughly before adding code to protect and unprotect sheets (or at the very least comment the code out until you're nearly finished). My experience has been that debugging code that has protect/unprotect commands in it can be a royal pain.


enjoy