Consulting

Results 1 to 5 of 5

Thread: Protect method

  1. #1

    Protect method

    in the following line of code (from a worksheet protect macro):

    mySheet.Protect "Password", True, True, True
    do the three "true" statements refer to drawing objects, contents and scenarios?

  2. #2

  3. #3
    Thanks, Zack. It never hurts to receive confirmation from an expert

  4. #4
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    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:
    Quote Originally Posted by VBA Help File: Protect Method
    If you apply the Protect method with the UserInterfaceOnly argument set to True to a worksheet and then save the workbook, the entire worksheet (not just the interface) will be fully protected when you reopen the workbook. To unprotect the worksheet but re-enable user interface protection after the workbook is opened, you must again apply the Protect method with UserInterfaceOnly set to True.
    You can set it using an additional True argument, like:
    mySheet.Protect "Password", True, True, True, True
    Or, to make sure you understand what is being sent to the Protect method, you could specify the arguments:
    mySheet.Protect "Password", DrawingObjects:=True, Contents:=True, _
      Scenarios:=True, UserInterfaceOnly:=True

  5. #5
    thanks for the tips. The worksheet protection macro that I normally use specifies the arguments as you recommend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •