Salut a tous j'ai un petit problème au niveau d'une macro me servant à déprotéger des classeurs. Un message d'erreur me dit que le mdp n'est pas correct alors qu'il l'est en fait. Pourriez vous m'aider voici le code.
Code:
Option Explicit
Sub UnProtectMany()
Dim vaFileName As Variant
Dim MyDir$
MyDir = Sheets("iZiCompta").Range("C21").Text
'the location of the workbooks
With Application.FileSearch
.NewSearch
.LookIn = MyDir
'the directory to search in
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then
'workbooks found
For Each vaFileName In .FoundFiles
'loop through each found workbook
Unprotect vaFileName
'pass workbook fullname to unprotect routine
Next
Else
MsgBox "Aucun fichier Excel trouvé."
End If
End With
End Sub
Sub Unprotect(wbkName)
Dim ws As Worksheet
With Application
.ScreenUpdating = False
.AskToUpdateLinks = False
End With
Workbooks.Open Filename:=wbkName, IgnoreReadOnlyRecommended:=True
With ActiveWorkbook
.RunAutoMacros xlAutoOpen
.Unprotect Password:="otersav"
For Each ws In .Worksheets
ws.Unprotect Password:="otersav"
Next ws
.Close True
End With
End Sub