Code:
Sub MyFileListAtMyFolder() '
Dim myPathAndFiles As String
Let myPathAndFiles = "D:\test\*.xls*" '
Dim StrDirBack As String
Let StrDirBack = Dir(myPathAndFiles, vbNormal) ' Initial file search for all Excel files - * is a wildcard, so any file like MyFile.xlsx or BN.xls etc. will meet the search criteria - the file need only have .xls in it
Do While Not StrDirBack = "" ' Dir will return "" if no next file is found
Dim MyFilesList As String
Let MyFilesList = MyFilesList & vbCr & vbLf & StrDirBack ' add a line and the next found file name to our file list
Let StrDirBack = Dir ' If Dir is used with no arguments, then it looks for the next file with the previous serach criteria
Loop '
MsgBox Prompt:=MyFilesList, Title:="My Files from " & myPathAndFiles
End Sub
Bookmarks