Sub testx()
t = DirList("H:\")
[A1].Resize(UBound(t)) = Application.Transpose(t)
End Sub
Function DirList(Dossier As String, Optional recall As Boolean = False, Optional tbl As Variant) As Variant
Dim ItemVu As String, directory As Variant, SubFolderCollection As Collection, i As Long, a As Long, E As Long, criteres, arr1, arr2
Set SubFolderCollection = New Collection
arr1 = Array("a^", "a¨", "a`", "e^", "e¨", "i^", "i¨"): arr2 = Array("â", "ä", "à", "ê", "ë", "î", "ï")
If recall = False Then ReDim tbl(0) ' si recall on redim un tableau de zero item (pour la creation du tableau)
On Error Resume Next 'gestion des fichiers dossiers system et interdit ou generant une erreur(PerLog,recycle,etc..)
criteres = vbDirectory Or vbSystem Or vbHidden 'Or vbArchive Or ReadOnly Or vbNormal
ItemVu = Dir(Dossier, criteres)
If Error.Number = 0 Then ' si pas d'erreur on examine le contenu
'examen du dossier courrant
Do While ItemVu <> vbNullString
If Left(ItemVu, 1) <> "." Then
On Error Resume Next
If (GetAttr(Dossier & ItemVu) And vbDirectory) = vbDirectory Then
SubFolderCollection.Add Dossier & ItemVu
Else
For q = 0 To UBound(arr1): ItemVu = Replace(Replace(ItemVu, arr1(q), arr2(q)), UCase(arr1(q)), UCase(arr2(q))): Next
a = UBound(tbl) + 1: ReDim Preserve tbl(1 To a): tbl(a) = Dossier & ItemVu
End If
End If
ItemVu = Dir()
Loop
Else
Err.Clear
End If
'examen des sub dossier
For Each subdossier In SubFolderCollection
For q = 0 To UBound(arr1): subdossier = Replace(Replace(subdossier, arr1(q), arr2(q)), UCase(arr1(q)), UCase(arr2(q))): Next
If GetAttr(subdossier) <> vbDirectory Then a = UBound(tbl) + 1: ReDim Preserve tbl(1 To a): tbl(a) = subdossier
DirList subdossier & "\", True, tbl
Next subdossier
DirList = tbl
End Function