1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Dim ListeFic() As String, Fs
Sub SansMDP()
Dim i As Long, Wkb As Workbook
ReDim ListeFic(1 To 1)
Set Fs = CreateObject("Scripting.FileSystemObject")
ListeFichiers "C:\Users\Toto\Desktop\test\", "*.xls*"
Application.ScreenUpdating = False
If ListeFic(UBound(ListeFic)) = "" Then ReDim Preserve ListeFic(1 To UBound(ListeFic) - 1)
Application.DisplayAlerts = False
For i = LBound(ListeFic) To UBound(ListeFic)
Set Wkb = Workbooks.Open(Filename:=ListeFic(i), UpdateLinks:=2, Password:="toto")
Wkb.SaveAs Filename:=ListeFic(i), Password:=""
Wkb.Close False
Next i
Set Fs = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox UBound(ListeFic) & " fichiers traités"
End Sub
Sub ListeFichiers(Dossier As String, NomFic As String)
Dim Fic, Doss
For Each Fic In Fs.Getfolder(Dossier).Files
If ListeFic(UBound(ListeFic)) <> "" Then ReDim Preserve ListeFic(1 To UBound(ListeFic) + 1)
If Fic.Name Like NomFic Then ListeFic(UBound(ListeFic)) = Fic.Path
Next Fic
For Each Doss In Fs.Getfolder(Dossier).subFolders
ListeFichiers Doss.Path & "\", NomFic
Next Doss
End Sub |
Partager