Application.FileSearch

  • Thread starter Thread starter Cleberton(Brazilian)
  • Start date Start date
C

Cleberton(Brazilian)

I need help to use this application...
The problem is that I installed the new version of Office and my program
were made in Excel 2003.
I used this code:

With Application.FileSearch
.LookIn = "C:\Users\Cleber\Documents\SAUF\Coordenada\SAUCOO\"
.Filename = nome_arquivo
.MatchTextExactly = True
If .Execute > 0 Then
busca = 1
Else
busca = 0
End If
End With

but in Excel 2007 it does not work!
I don't know and I tried a lot of other ways that I found in the help option
but all of them failed..
If somebody could help, please is much important.!
I'm a little new in VBA.
Thanks...
 
Application.FileSearch is not going to work in 2007..You can try this
alternative function which uses the FileSystemObject...


Function GetFileCount(strPath As String) As Long
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
GetFileCount = -1
GetFileCount = fso.GetFolder(strPath).Files.Count
End Function

If this post helps click Yes
 
to check whether the file exists you can try

If Dir("c:\temp\1.xls",vbNormal) = "" Then
Msgbox "File not found"
Else
'file exists. do something
End If

If this post helps click Yes
 
Back
Top