I want to protect all the sheets in a workbook based on username, so workbooks will be protected from external use, whereas internally we can easily use. However, the code just always states that the line If ws.Protect = True Then is false, even when I know the sheet is protected...

```
Private Sub Workbook_Open()
Dim strUser, Num, myCount, ws

    strUser = CreateObject("WScript.Network").UserName
    strUser = LCase(strUser)
    Num = CLng(Right(strUser, 6))

    If Left(strUser, 1) = "D" And Len(strUser) = 11 And IsNumeric(Num) Then
    For Each ws In ActiveWorkbook.Worksheets
    If ws.Protect = True Then
        ws.Unprotect "password"
    Else
        ws.Protect "password", DrawingObjects:=True, Contents:=True, _
                        AllowSorting:=True, AllowFiltering:=True
    End If
    Next ws
    End If

End Sub

```

any help would be appreciated!