View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Checking to see if a file exists.

Dim TestStr as string
teststr = ""
on error resume next
teststr = dir("Yourpathtothefile\yourfilename.ext")
on error goto 0

if teststr = "" then
'not there
else
'yes, it is!
end if



JHB wrote:

I would like to create a macro that will check to ensure that a file
exists, which will have a material efefct on the steps to be taken
next. I am havintg trouble finding out how to do this. Can someone
tell me the command argument for an if command that would make the
check, as if:

IF Exists xxx.xls then
else
endif

Thanks a lot.

John Baker


--

Dave Peterson