Sub cc()
Dim MyPath As String, MyName As String, TName() As String
MyPath = "D:\"
MyName = MyPath & "*.xls"
n = CreateObject("Scripting.FileSystemObject").GetFolder(MyPath).Files.Count
ReDim TName(1 To n)
MyName = Dir(MyName)
i = 0
Do While MyName <> ""
if instr(MyName,"xls") then
i = i + 1
TName(i) = MyName
end if
MyName = Dir
Loop
End Sub