MrExcel Publishing
Your One Stop for Excel Tips & Solutions

test for the existence of another excel file

Posted by Robert Yerby on August 23, 2000 12:26 AM

I am trying to write a VBA procedure that will copy in data
from another spreadsheet which may not yet have been created.
Does anyone know the code for this? I also intend that the
procedure should perform the test every (say) 20 seconds until
the file is there but I think I know that code.
Any help gratefully received.

Posted by Michael Liu on August 23, 0100 6:30 AM

before the copy code, you'll want to check for
the file using something like this:

FileName = "H:\test3.xls"
Do While Dir(FileName) = ""
Application.Wait (Now + TimeValue("0:00:20"))

'open workbook and copy code goes here

Posted by robert yerby on August 23, 0100 11:44 AM

Thanks very much.