Aide pour compléter ce code vba

Résolu
Bonjour,

Je ne suis pas du tout expert en vba et j'ai trouvé cette syntase d'un code que j'aimerais changer en deprotection :
le voici :

Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If Not sh.ProtectContents Or Not sh.ProtectDrawingObjects Then
sh.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Merci

2 réponses

  • Votes
  • Date
  • Date décroissante
  1. Bonjour,
    La modification suivante devrait fonctionner :
    Sub deprotect()
        Dim sh As Worksheet
        For Each sh In ThisWorkbook.Worksheets
            If sh.ProtectContents Or sh.ProtectDrawingObjects Then
                sh.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
            End If
        Next
    End Sub
    1. Bonjour didibonf,

      Tellement logique le "False" que je n'y ai pas pensé.
      Grand merci pour le coup de main.
      Je peux terminé ma macro tranquillement.

      RESOLU..