Bonjour à tous
De manière à protéger simultanément les feuilles d'un même classeur j'utilise les macros suivantes :
Dans "ThisWorbook" : Private Sub Workbook_Open()
For Each sh In Sheets
sh.Protect "TOTO"
Next sh
Feuil1.CommandButton2.Visible = False
Feuil1.CommandButton1.Visible = True
End Sub
et Dans ma Feuil1 Private Sub CommandButton1_Click()
mdp = InputBox("Veuillez entrer le mot de passe, svp", "Déprotection")
If mdp = "" Then Exit Sub
If mdp <> " TOTO " Then
MsgBox "vous n'avez pas les droits"
Else
For Each sh In Sheets
sh.Unprotect mdp
Next sh
Me.CommandButton1.Visible = False
Me.CommandButton2.Visible = True
End If
End Sub
Private Sub CommandButton2_Click()
For Each sh In Sheets
sh.Protect " TOTO "
Next sh
Me.CommandButton1.Visible = True
Me.CommandButton2.Visible = False
End Sub
Il n'en reste pas moins qu'une fois protégé, je n'ai plus accès à la fonctionnalité PLAN
Et j'avoue humblement ne pas savoir comment modifier mes lignes de commande en conséquence
Merci Pierrot
Mais mon intelligence me fait défaut...
Cela ne fonctionne que sur le feuille 1
Comment faire pour le généralisé sur toutes les feuilles...
Encore merci d'avance
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
With ws
.EnableOutlining = True
.Protect "toto", userinterfaceonly:=True
End With
Next ws
End Sub