• check if a worksheet is protected (XL2003NL)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » check if a worksheet is protected (XL2003NL)

    • This topic has 3 replies, 3 voices, and was last updated 16 years ago.
    Author
    Topic
    #459452

    Hello all,
    How could I check with VBA if a worksheet is protected?

    Thanks in advance for your answer
    Greetings,
    Patick Schouten

    Viewing 2 reply threads
    Author
    Replies
    • #1158499

      Hello all,
      How could I check with VBA if a worksheet is protected?

      Thanks in advance for your answer
      Greetings,
      Patick Schouten

      Hi Patrick,

      For a workbook, you could try something based on:
      If ThisWorkbook.ProtectStructure = True Or ThisWorkbook.ProtectWindows = True Then …

      For a Worksheet, you could try something based on:
      If ThisWorkbook.Worksheets(1).ProtectContents = True Then …

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1158500

      You can inspect the ProtectContents property of the sheet. From the Excel VBA help:

      Code:
      If Worksheets("Sheet1").ProtectContents = True Then
      	MsgBox "The contents of Sheet1 are protected."
      End If
    • #1158501

      Thanks,

      It works.

      greetings,
      Patrick

    Viewing 2 reply threads
    Reply To: check if a worksheet is protected (XL2003NL)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: