in the following line of code (from a worksheet protect macro):
do the three "true" statements refer to drawing objects, contents and scenarios?mySheet.Protect "Password", True, True, True
in the following line of code (from a worksheet protect macro):
do the three "true" statements refer to drawing objects, contents and scenarios?mySheet.Protect "Password", True, True, True
Yes.
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
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: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:mySheet.Protect "Password", True, True, True, True
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