How to check if external .txt file has text in it...

G

Guest

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.
 
T

Tom Ogilvy

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 said:
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.
 
G

Guest

Thanks a bunch. I really appreciate it.

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


FileLen: ' Returns file length (bytes).

--
Regards,
Tom Ogilvy




Thanks.
 

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