Bonjour,
je souhaiterai avoir vos avis sur mon code svp.
pour modifier un fichier ou j'ai mit un MDP, je doit ôter la protection.
J'aimerai qu'une fois mon fichier xls fermer, la macro re-protège automatiquement le fichier
après pas mal de recherche sur le forum j'en ai ressorti ce code, mais ne fonctionne toujours pas.. :
Sub WsLock(Optional y)
Dim PWd$
PWd = "alan"
'Protège ou déprotège toutes les feuilles
Application.ScreenUpdating = False
If IsMissing(y) Then
For i = 1 To Worksheets.Count
Worksheets(i).Protect PWd
[A1].Select
Next
Else
For i = 1 To Worksheets.Count
Worksheets(i).Unprotect PWd
[A1].Select
Next
End If
End Sub
Sub deprotege(Optional y)
WsLock 0
Dim PWd$
PWd = "alan"
'Protège ou déprotège toutes les feuilles
Application.ScreenUpdating = False
If IsMissing(y) Then
For i = 1 To Worksheets.Count
Worksheets(i).Protect PWd
[A1].Select
Next
Else
For i = 1 To Worksheets.Count
Worksheets(i).Unprotect PWd
[A1].Select
Next
End If
End Sub
Sub protege(Optional y)
WsLock
Dim PWd$
PWd = "alan"
'Protège ou déprotège toutes les feuilles
Application.ScreenUpdating = False
If IsMissing(y) Then
For i = 1 To Worksheets.Count
Worksheets(i).Protect PWd
[A1].Select
Next
Else
For i = 1 To Worksheets.Count
Worksheets(i).Unprotect PWd
[A1].Select
Next
End If
End Sub
Merci d'avance pour votre aide !