View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to check if external .txt file has text in it...

Dim fName as String
fName = "C:\MyFolder\myfile.txt"
If FileLen(fName) < 10 then exit sub


FileLen: ' Returns file length (bytes).

--
Regards,
Tom Ogilvy



"LL Cool A" wrote in message
...
Hi everyone,

I've recorded a macro that imports a .txt file generated from other
software. The .txt file that the other software generates sometimes has

text
in it and sometimes doesn't have text in it, updated about every 10 secs.

The
problem is that when the external .txt file is completely empty, my macro
chrashes. I need help on writing code that will check if the external .txt
file has text in it. If so, the macro will keep running. Otherwise, it

will
then wait some period of time. Any help would be greatly appreciated.

Thanks.