in the following line of code (from a worksheet protect macro):
do the three "true" statements refer to drawing objects, contents and scenarios?Code:mySheet.Protect "Password", True, True, True
Printable View
in the following line of code (from a worksheet protect macro):
do the three "true" statements refer to drawing objects, contents and scenarios?Code:mySheet.Protect "Password", True, True, True
Yes. :yes
Thanks, Zack. It never hurts to receive confirmation from an expert
Whenever I protect a sheet via code, I always include the UserInterfaceOnly argument. What this does is protect the sheet from the user after it is run, but allows vba code to run as if the sheet were unprotected. Note, though, that this only applies to that specific instance of the file being opened. If you protect it with UserInterfaceOnly, save the file, and close it, when you re-open the file it will have to be re-protected with UserInterfaceOnly for the benefits to apply. A note from the help files:
You can set it using an additional True argument, like:Quote:
Originally Posted by VBA Help File: Protect Method
Or, to make sure you understand what is being sent to the Protect method, you could specify the arguments:Code:mySheet.Protect "Password", True, True, True, True
Code:mySheet.Protect "Password", DrawingObjects:=True, Contents:=True, _
Scenarios:=True, UserInterfaceOnly:=True
thanks for the tips. The worksheet protection macro that I normally use specifies the arguments as you recommend