how to check if the file exists or not

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
 
H

Harald Staff

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
 

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

Top