Results 1 to 4 of 4
  1. #1
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hello all,
    How could I check with VBA if a worksheet is protected?

    Thanks in advance for your answer
    Greetings,
    Patick Schouten
    Greetings,

    Patrick Schouten
    (The Netherlands)

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='siflaar' post='772835' date='29-Apr-2009 19:41']Hello all,
    How could I check with VBA if a worksheet is protected?

    Thanks in advance for your answer
    Greetings,
    Patick Schouten[/quote]
    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
    [MS MVP - Word]

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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

  4. #4
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks,

    It works.

    greetings,
    Patrick
    Greetings,

    Patrick Schouten
    (The Netherlands)

Posting Permissions

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