Dim fso As Object, liste, n& 'mémorise les variables
Sub EcraserFichiers()
Dim debut$, chemin$, nom$
With ThisWorkbook
debut = "E:\Logiciels\00 - PROJETS"
chemin = .Path
nom = LCase(.Name) 'minuscules
Set fso = CreateObject("Scripting.FileSystemObject")
ReDim liste(0) 'RAZ
n = 0 'RAZ
ListeRecursive fso.getfolder(debut), nom
Application.DisplayAlerts = False
If n Then
For n = 0 To UBound(liste)
.SaveAs liste(n)
Next
End If
MsgBox IIf(n, n, "Aucun") & " fichier" & IIf(n > 1, "s", "") & " écrasé" & IIf(n > 1, "s", "") & " dans les sous-dossiers"
.SaveAs chemin & "\" & nom
End With
Set fso = Nothing
End Sub
Sub ListeRecursive(f As Object, nom$)
Dim sf As Object, fich As Object
For Each sf In f.subfolders
For Each fich In fso.getfolder(sf).Files
If LCase(fich.Name) = nom Then
ReDim Preserve liste(n)
liste(n) = sf & "\" & nom
n = n + 1
End If
Next fich
ListeRecursive fso.getfolder(sf), nom
Next sf
End Sub