Function replaceAllCsvHeader(Dossier)
Dim FsO As Object, fich, x&, subdossier, contenu As String
Set FsO = CreateObject("Scripting.FileSystemObject")
Set Dossier = FsO.GetFolder(Dossier)
For Each fich In Dossier.Files
If LCase(Right(fich, 4)) = ".csv" Then
'lecture
With CreateObject("ADODB.Stream")
.Charset = "utf-8": .Open: .LoadFromFile (fich): contenu = .ReadText()
End With
'ecriture
With CreateObject("ADODB.Stream")
.Type = 2: .Charset = "utf-8": .Open: .WriteText Replace(contenu, oldChaine, NewChaine)
.SaveToFile fich, 2
End With
End If
Next
For Each subdossier In Dossier.subfolders
replaceAllCsvHeader subdossier.Path
Next subdossier
Set FsO = Nothing
End Function