Import file names in Excel


I have a folder with a series of Outlook files (with the .msg extension), and I want to import all file names in an Excel file (2007). Is there any macro for this purpose?


Adapt this code accordingly:
Sub repertorier_fichier()
Dim Chemin As String, Fichier As String

'indique le répertoire contenant les fichiers
Chemin = "C:\MONDOSSIER\"

'Boucle sur tous les fichiers msg du répertoire.
Fichier = Dir(Chemin & "*.msg")

numligne = 1

Do While Len(Fichier) > 0
Sheets("Feuil1").Range("A" & numligne).Value = Fichier
numligne = numligne + 1
Fichier = Dir()
End Sub

Thanks to rv83toulon for this tip.
Published by aakai1056. Latest update on October 15, 2014 at 04:00 AM by Jeff.
This document, titled "Import file names in Excel," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Excel - Using SUMIF function with two criteria
Excel - Convert numbers to words