Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

oter un mot de passe sur un dossier excel

  • Initiateur de la discussion Initiateur de la discussion leanoor
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

L

leanoor

Guest
Bonjour, j'ai mis, il ya qqs mois un mot de passe sur un dossier excel pour mes enfants et je ne le connais plus. Que puis-je faire?
 
Re : oter un mot de passe sur un dossier excel

Ecrit ce code dans un module & lance-le
A +

Public Sub Suppression_Toute_Protection()
Const DBLSPACE As String = vbNewLine & vbNewLine
Const ALLCLEAR As String = DBLSPACE & "Les protections ont intégralement été retirées..."
Const MSGNOPWORDS1 As String = "Pas de protection trouvée... "
Const MSGNOPWORDS2 As String = "Pas de protection au niveau classeur, Déprotection des onglets en cours"
Const MSGTAKETIME As String = "Et c'est parti, bon café..."
Const MSGPWORDFOUND1 As String = "Mot de passe trouvé : " & DBLSPACE & "$$"
Const MSGPWORDFOUND2 As String = "Mot de passe trouvé : " & DBLSPACE & "$$"
Const MSGONLYONE As String = "Seul le classeur était protégé, plus de mot de passe"
Dim w1 As Worksheet, w2 As Worksheet
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean

Application.ScreenUpdating = False
With ActiveWorkbook
WinTag = .ProtectStructure Or .ProtectWindows
End With
ShTag = False
For Each w1 In Worksheets
ShTag = ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation
Else
On Error Resume Next
Do 'dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
With ActiveWorkbook
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If .ProtectStructure = False And _
.ProtectWindows = False Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND1, _
"$$", PWord1), vbInformation
Exit Do 'Bypass all for...nexts
End If
End With
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
If WinTag And Not ShTag Then
MsgBox MSGONLYONE, vbInformation
Exit Sub
End If
On Error Resume Next
For Each w1 In Worksheets
'Attempt clearance with PWord1
w1.Unprotect PWord1
Next w1
On Error GoTo 0
ShTag = False
For Each w1 In Worksheets
'Checks for all clear ShTag triggered to 1 if not.
ShTag = ShTag Or w1.ProtectContents
Next w1
If ShTag Then
For Each w1 In Worksheets
With w1
If .ProtectContents Then
On Error Resume Next
Do 'Dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If Not .ProtectContents Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND2, _
"$$", PWord1), vbInformation
'leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
w2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for...nexts
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
End With
Next w1
End If
MsgBox ALLCLEAR & REPBACK, vbInformation
End Sub
 
Re : oter un mot de passe sur un dossier excel

Bonsoir,

et ça fonctionne très bien ce fichier, mais le balancer en public, je ne sais pas si c'est très prudent 😕
enfin, ce n'est que mon avis....qui n'engage que moi 😎
 
Re : oter un mot de passe sur un dossier excel

Bonsoir,

et ça fonctionne très bien ce fichier, mais le balancer en public, je ne sais pas si c'est très prudent 😕
enfin, ce n'est que mon avis....qui n'engage que moi 😎

Oui j'ai pense a ca avant de le poster mais j'ai voulu juste donne de l'aide a notre ami. c'est a lui de l'utilser d'une facon l'egale juste pour son fichier personnel.
@ + +
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

Réponses
7
Affichages
343
Réponses
3
Affichages
222
  • Question Question
Microsoft 365 Fonction si
Réponses
7
Affichages
223
  • Question Question
Réponses
6
Affichages
416
Réponses
19
Affichages
867
Réponses
17
Affichages
880
Réponses
18
Affichages
601
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…