![]() |
How to check if external .txt file has text in it...
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. |
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. |
How to check if external .txt file has text in it...
Thanks a bunch. I really appreciate it.
"Tom Ogilvy" wrote: 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. |
All times are GMT +1. The time now is 06:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com