'Auteur : Ken Puls
[FONT=Courier]Option Explicit
Private Function SheetProtected(TargetSheet As Worksheet) As Boolean
'Function purpose: To evaluate if a worksheet is protected
If TargetSheet.ProtectContents = True Then
SheetProtected = True
Else
SheetProtected = False
End If
End Function
Sub SimpleTest()
'Macro purpose: To demonstrate use of SheetProtected Function
'*** THIS MACRO FOR ILLUSTRATIVE PURPOSES ONLY ***
'*** AND IS NOT REQUIRED TO USE THE ABOVE FUNTION! ***
'Assign active worksheet to variable to be tested
Dim ws As Worksheet
Set ws = ActiveSheet
'Test the activesheet's protection
If SheetProtected(ws) Then
'If protected
MsgBox "Sorry, but " & ws.Name & " is protected!", _
vbOKOnly + vbInformation, ws.Name & " is protected!"
Else
'If not protected
MsgBox "Hooray! " & ws.Name & " is not protected!", _
vbOKOnly + vbInformation, ws.Name & " is unprotected!"
End If
End Sub [/FONT]