I've never actually used the Name function, in fact I never actually used the FileSearch either. Looking through your code, it looks like all you're doing is moving the excel files from startdir and startdir's subdirs to enddir. I don't really understand what you're opening the file, saving it, and closing it. Using FileSearch, you could do:
Sub FindClientExcelFiles()
Dim vaFileName As Variant
Dim startdir As String
Dim enddir As String
Dim Foo As Workbook
Dim fsoObj As Object
enddir = ("C:\Temp\" & Format(Date, "MMDDYYYY") & "\")
startdir = "C:\Temp\1"
Set fsoObj = CreateObject("Scripting.FileSystemObject")
If Not fsoObj.FolderExists(enddir) Then fsoObj.CreateFolder enddir
With Application.FileSearch
.NewSearch 'Clear old search criteria
.LookIn = startdir 'Directory to search
.SearchSubFolders = True 'Include sub folders in search
.FileType = msoFileTypeExcelWorkbooks 'Look for Excel files
.LastModified = msoLastModifiedAnyTime 'Doesn't matter when last modified
For Each vaFileName In .FoundFiles 'List the files in the
'FoundFiles collection
Set Foo = Workbooks.Open(vaFileName)
Foo.SaveAs enddir & Foo.Name
Foo.Close
Kill vaFileName
Next vaFileName
End With
Set fsoObj = Nothing
End Sub
If I were doing it, I would use the file system object for the entire thing:
Sub FindClientExcelFiles()
Dim fso As Object
Dim startdir As String
Dim enddir As String
enddir = ("C:\Temp\" & Format(Date, "MMDDYYYY") & "\")
startdir = "C:\Temp\1"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(enddir) Then fso.CreateFolder enddir
Application.ScreenUpdating = False
ProcessFolder fso.GetFolder(startdir), fso, enddir
Application.ScreenUpdating = True
Set fso = Nothing
End Sub
Public Function ProcessFolder(fld As Object, fso As Object, ByVal eDir As String)
Dim f As File
Dim fl As Folder
For Each f In fld.Files
If LCase(Right(f.Name, 3)) = "xls" Then
If fso.FileExists(eDir & f.ShortName) Then fso.DeleteFile eDir & _
f.ShortName
fso.MoveFile f, eDir & f.ShortName
End If
Next
For Each fl In fld.SubFolders
ProcessFolder fl, fso, eDir
Next fl
Set f = Nothing
Set fl = Nothing
End Function
But how you choose to do it is up to you!
Matt