XL 2016 verrouiller feuilles avec mdp VBA

Quentin62000

XLDnaute Nouveau
Bonjour a tous en cherchant sur le forum j'ai trouver cette formules pour verrouiller toute mes feuilles , cependant , il ne me demande pas de mdp pourquoi ??
Public Sub AvecProtection()

Dim wsh As Worksheet
Dim myPassword As String

myPassword = "1234"

For Each wsh In Application.ThisWorkbook.Worksheets
wsh.Protect myPassword, UserInterfaceOnly:=True
Next wsh

MsgBox "Protection activée", vbInformation

End Sub


Public Sub SansProtection()

Dim wsh As Worksheet
Dim myPassword As String

myPassword = "1234"

For Each wsh In Application.ThisWorkbook.Worksheets
wsh.Unprotect myPassword
Next wsh

MsgBox "Protection désactivée", vbInformation

End Sub
 

Jacky67

XLDnaute Barbatruc
Bonjour a tous en cherchant sur le forum j'ai trouver cette formules pour verrouiller toute mes feuilles , cependant , il ne me demande pas de mdp pourquoi ??
Public Sub AvecProtection()

Dim wsh As Worksheet
Dim myPassword As String

myPassword = "1234"

For Each wsh In Application.ThisWorkbook.Worksheets
wsh.Protect myPassword, UserInterfaceOnly:=True
Next wsh

MsgBox "Protection activée", vbInformation

End Sub


Public Sub SansProtection()

Dim wsh As Worksheet
Dim myPassword As String

myPassword = "1234"

For Each wsh In Application.ThisWorkbook.Worksheets
wsh.Unprotect myPassword
Next wsh

MsgBox "Protection désactivée", vbInformation

End Sub
Bonjour,
Le code fait exactement ce qui lui est demander, le mot de passe étant inscrit en dur
A la protection, il est impossible d'écrire sur les feuilles
Mais....
S'il s'agit de demander le mot de passe avant de déprotéger les feuilles, voir l'exemple en pièce jointe
 

Pièces jointes

  • Quentin_MDP.xlsm
    24.9 KB · Affichages: 9

Discussions similaires

Réponses
7
Affichages
390

Statistiques des forums

Discussions
312 413
Messages
2 088 199
Membres
103 765
dernier inscrit
Pi4