Bonjour à tous,
Merci du tuyau, j'ai regardé en détail la fonction DIR ce qui m'a permis d'avancer. Le programme ci-dessous fonctionne, mais il ne me donne que les fichiers contenus directement dans le dossier "G:\NEW RDFs\"
Je dois aussi lister et compter tous les fichiers contenus dans tous les sous-dossiers dont le nom n'est pas connu.
ex) je veux voir tous les fichiers *.dlog contenus dans
"G:\NEW RDFs\LILLE\" ainsi que dans "G:\NEW RDFs\PARIS\", etc...
Les noms de Lille, Paris, .. peuvent être quelconque.
Merci par avance de votre coup de pouce
michels91
Sub ListFiles()
Dim strPath As String
Dim strFile As String
Dim NextRow As Long
'Spécifie le chemin path du dossier
strPath = "G:\NEW RDFs\"
'S'assure que le path finit avec un backslash
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
'Get the first file from the folder
strFile = Dir(strPath & "*.*", vbNormal
'Si pas fichier trouvé, exit le sub
If Len(strFile) = 0 Then
MsgBox "No files were found...", vbExclamation
Exit Sub
End If
'Turn off screen updating
Application.ScreenUpdating = False
'Insert the headers for Columns A, B, and C
Cells(1, "A").Value = "FileName"
Cells(1, "B").Value = "Size"
Cells(1, "C").Value = "Date/Time"
'Find the next available row
NextRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
'Loop through each file in the folder
Do While Len(strFile) > 0
'List the name, size, and date/time of the current file
Cells(NextRow, 1).Value = strFile
Cells(NextRow, 2).Value = FileLen(strPath & strFile)
Cells(NextRow, 3).Value = FileDateTime(strPath & strFile)
'Determine the next row
NextRow = NextRow + 1
'Get the next file from the folder
strFile = Dir
Loop
'Turn screen updating back on
Application.ScreenUpdating = True
End Sub