how to check if the file exists or not

  • Thread starter Thread starter Mili
  • Start date Start date
M

Mili

Hi,

I would like to display as true or false depending upon
the existance of a specified file in the directory.

if yes display true
or display false.

I am using office 2000
i am using following code :
'*******************************************************
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("c:\test\file1.txt")
s = f.DateCreated
MsgBox " File Name := " & f.Name & " File Created on := "
& s & "Header File := " & headerTemplate & " File
Exists := " & fs.DriveExists(headerTemplate)
'*******************************************************

Thanks

Regards

Mili
 
Hi Mili

Sub test()
MsgBox FileXists("c:\test\file1.txt")
End Sub

Function FileXists(fName As String) As Boolean
On Error Resume Next
FileXists = Len(Dir(fName))
End Function
 
Back
Top