D
David Howlett
I am trying to test for the existance of files. For example, to see if the
file "analyst1.mdb" exists or not. The following code sets 'result' to true
even if the file "analyst1.mdb" does not exist. There is however a file
named "analyst10.mdb".
With Application.FileSearch
.NewSearch
.LookIn = "C:\temp"
.SearchSubFolders = False
.FileName = "analyst1.mdb"
.MatchTextExactly = True
result = (.Execute > 0)
end with
I tried to write a new function:
Function DoesFileExist(f)
Dim sourcefile
On Error GoTo cantOpen
sourcefile = FreeFile
Open sourcefile For Binary Access Read As sourcefile
GoTo theEnd
cantOpen:
DoesFileExist = False
Exit Function
theEnd:
DoesFileExist = LOF(sourcefile) > 0
Close sourcefile
End Function
But it always returns false! lof is always 0, even if the file exists.
Can someone help?
file "analyst1.mdb" exists or not. The following code sets 'result' to true
even if the file "analyst1.mdb" does not exist. There is however a file
named "analyst10.mdb".
With Application.FileSearch
.NewSearch
.LookIn = "C:\temp"
.SearchSubFolders = False
.FileName = "analyst1.mdb"
.MatchTextExactly = True
result = (.Execute > 0)
end with
I tried to write a new function:
Function DoesFileExist(f)
Dim sourcefile
On Error GoTo cantOpen
sourcefile = FreeFile
Open sourcefile For Binary Access Read As sourcefile
GoTo theEnd
cantOpen:
DoesFileExist = False
Exit Function
theEnd:
DoesFileExist = LOF(sourcefile) > 0
Close sourcefile
End Function
But it always returns false! lof is always 0, even if the file exists.
Can someone help?