Sub FindXLS()
Dim FS As FileSearch
Dim FilePath As String, FileSpec As String
FilePath = "C:\Test\" '<----- Edit as needed
FileSpec = "*.xls"
Set FS = Application.FileSearch
With FS
.LookIn = FilePath
.FileName = FileSpec
.Execute
If .FoundFiles.Count = 0 Then
MsgBox "No Files Found"
Exit Sub
Else
'Your code here
End If
End With
End Sub
Sub Test()
Dim strPath as String, strFilter as String, strResult as String
strPath = "C:\" 'amend as appropriate
strFilter = "*.xls" 'amend as appropriate
strResult = strPath & "\" & strFilter
If strResult<>"" Then
'xls file found!!! COde as appropriate
End If
End Sub
Richard
Is your code perhaps missing a little something?
Like Dir?
Sub Test()
Dim strPath as String, strFilter as String, strResult as String
strPath = "C:\" 'amend as appropriate
strFilter = "*.xls" 'amend as appropriate
strResult = Dir(strPath & "\" & strFilter)
If strResult<>"" Then
'xls file found!!! COde as appropriate
End If
End Sub
So the Filesearch method is no more? That stinks. I guess I will need to get more familiar with DIR. I wonder what the reasoning was on that decision.