File Search

  • Thread starter Thread starter unplugs
  • Start date Start date
U

unplugs

GOod day all..

How to do file search?

I had reading some codes in this forum.. But none suit m
application..

I want to search a file(file name is dummy for first time created
whether it exists or not, if not exists, it will create the dummy.txt
if this file name(dummy.txt) exists, it will automatically assig
another name to it, for example, Engine001, and it will search agai
and check whether this file name(Engine001) exist or not. If exist, i
will create another file name, Engine002 .... until the file name i
not exists in the folder, it will use the file name and move on t
store data in the file.

How to do the search for the above application?

Helps from anyone is appreciated~
:
 
Function FileExists(fname As String) As Boolean
With Application.FileSearch
.LookIn = "C:\ "
.NewSearch
.filename = fname
.Execute

If .FoundFiles.Count = 0 Then
FileExists = False
Else
FileExists = True
End If
End With
End Function



Can anyone help me to check whether the function above correct o
not..? When I debug the code above, whether the file exists or not, th
.FoundFiles.Count is alwaz equal to 0..... Why this happen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top