Protection des plans

CTR79

XLDnaute Nouveau
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 de votre aide.
 

Pierrot93

XLDnaute Barbatruc
Re : Protection des plans

Bonjour,

regarde ceci, procédure événementielle, se déclenche à l'ouverture du classeur à placer dans le module "thisworkbook" :
Code:
Option Explicit
Private Sub Workbook_Open()
With Feuil1
    .EnableOutlining = True
    .Protect "toto", userinterfaceonly:=True
End With
End Sub

bonne journée
@+
 

Pierrot93

XLDnaute Barbatruc
Re : Protection des plans

Re,

avec une boucle sur toutes les feuilles..
Code:
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
 

Discussions similaires

Réponses
14
Affichages
377
Compte Supprimé 979
C
Réponses
29
Affichages
722

Statistiques des forums

Discussions
312 069
Messages
2 085 042
Membres
102 765
dernier inscrit
richdi