patouman
XLDnaute Occasionnel
Bonjour, je pense avoir fais une erreur dans ma vba car je n'obtiens pas le résultat escompté. Je m'explique : j'ai un vba qui protege ou deprotege toutes les feuilles de mon classeur mais celle ci s'execute sans me demander un mot de passe.
Et justement je souhaite qu'un MDP soit obligatoire pour son éxécution
merci par avance
mon code :
Sub Protege(Optional Y)
Dim PWd$
PWd = "toto"
For i = 1 To Worksheets.Count
With Worksheets(i)
If IsMissing(Y) Then
If .ProtectContents = False Then .Protect PWd
Else
If .ProtectContents Then .Unprotect PWd
End If
End With
Next
End Sub
Sub Deprotege()
Protege 0
End Sub
Et justement je souhaite qu'un MDP soit obligatoire pour son éxécution
merci par avance
mon code :
Sub Protege(Optional Y)
Dim PWd$
PWd = "toto"
For i = 1 To Worksheets.Count
With Worksheets(i)
If IsMissing(Y) Then
If .ProtectContents = False Then .Protect PWd
Else
If .ProtectContents Then .Unprotect PWd
End If
End With
Next
End Sub
Sub Deprotege()
Protege 0
End Sub