Results 1 to 2 of 2

Thread: Can I find out if the Excel Workseet is protected?

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Does anybody know how to find if an Excel worksheet is protected?

    For example

    If (sheet1 is protected) Then
    MsgBox("Protected")
    Else
    MsgBox("Not Protected")
    End If

    I used .protect = true but this property actually protects
    the sheet rather than return a value

    Any ideas?
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Not sure what you are doing but if you simply test the .protect attribute it should give you the result.

    Code:
    If Sheet1.protect Then
      MsgBox "Protected"
    Else
      MsgBox "Unprotected"
    End If
    Don't forget by default all "If" statements evaluate to a boolean expression so you don't need to do "= true" or "= false" on the end as the attribute itself is boolean already

Posting Permissions

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



Click Here to Expand Forum to Full Width