does a file exist

A

Arien

I would like to make a True/False statement in an excel-formula that
checks
if a certain file exists on the harddisk or not.
There must be some kind of VBA statement for that.

Please let me know if you can help me. Thanks.

Arien de Haan
Eindhoven, NL
 
B

Bob Phillips

Best to add a UDF

Function BookExists(wb As String)
BookExists = Len(Dir(wb)) > 0
End Function

and use like

=IF(BookExists("C:\myfile.xls"), "yes","no")

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
G

Guest

Arien,

Here's some code I use to delete a dummy file from the C drive - I'm sure
you can adapt it to your needs.

Regards & happy New Year

Pete

If Dir("C:\Holidays+Training+Sickness Chart.xls") <> "" Then
Kill "C:\Holidays+Training+Sickness Chart.xls"
End If
 
A

Arien

It works. Thanks a lot.
regards, Arien de Haan



Bob said:
Best to add a UDF

Function BookExists(wb As String)
BookExists = Len(Dir(wb)) > 0
End Function

and use like

=IF(BookExists("C:\myfile.xls"), "yes","no")

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

message
 

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