checking for existance of file before running macro

J

Jim

I have a macro that opens a source file to retrieve information. I want to
be able to check to see if it's there first and if it's not send a msg to
the user stating that the file isn't there. When the user clicks okay on the
box I want the macro to end without error. Can anyone help?

thx, Jim
 
D

Dave Peterson

You can use the Dir() function:

dim myFilename as string
myfilename = "C:\autoexec.bat"
if dir(myfilename) = "" then
'it's not there
else
'yes, it is
end if
 
Top