Public Const C_PSW As String = "mot de passe" ' ou null
'**************exemple
sub mamacro1
deproteger
'
' mon code
'
proteger
end sub
Sub DeProteger()
WSProt = ActiveSheet.ProtectContents
ActiveSheet.Unprotect C_PSW
End Sub
Sub Proteger()
If WSProt = True Then ' remet la protection
With ActiveSheet
.EnableOutlining = True
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=C_PSW, _
AllowFiltering:=True
End With
End If
End Sub