Wait until file exist

B

Boris D.

Who knows a function, sub or something else, that
waits for coming file <FileSpecification> during N sec/min
and then returns
 
H

Helmut Weber

Hi Boris,
not tested, maybe typing errors:
sub anysub
checking:
if dir("c:\Myfile.doc") = "" then
wait(3) ' wait 3 seconds
goto checking:
endif
end sub
For "wait" have a look at:
http://www.google.de/groups?hl=de&lr=&ie=UTF-
8&threadm=072f01c3bef6%244e316c80%24a501280a%
40phx.gbl&rnum=1&prev=/groups%3Fas_q%3Dwait%26ie%3DISO-
8859-1%26as_ugroup%3Dmicrosoft.public.word.vba.general%
26as_uauthors%3DHelmut%2520Weber%26lr%3D%26hl%3Dde
Thread started by Jan Eliasen, 9. Dez. 2003

Note: Wait(), as defined there, does much more then
probably necessary. It would allow you, to wait
for several years.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, W98
 
P

Perry

Here's another one

Dim dStart As Date
dStart = Timer

'wait for presence of file or until 1 minute has elapsed
Do Until Dir("c:\temp\test.txt") <> "" Or _
DateDiff(n, Timer, dStart) > 1

DoEvents
Loop

If Dir("c:\temp\test.txt") = "" Then
MsgBox "File not created"
End If

Krgrds,
Perry
 

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