![]() |
Is there a way to add a timeout value to a line of code or functio
Is there a way to do a 'timeout' on a line of code or a function. I have a VBA program that downloads files from our FTP server and software updates from websites and saves them to specific folders on our computers. This is used to keep everyone up to date on project files etc. The problem is that sometimes the program hangs on waiting for a response from the server. I have to close Excel from the task manager and start again. Is there a way to put a timeout on the execution of a function or line of VBA code. I guess this could help in the event that a function has an infinite Do...Loop in it by mistake, you could say if the value is not determined/returned after X amount of time, return an invalid value. |
Is there a way to add a timeout value to a line of code or functio
Here is a delay macro that will pause your executing macro but allow
everthing else to run during the delay. You can set the time in tents of seconds or whole seconds by changing the numbe on line: s = Timer ? Public Function HalfSecDly() s = Timer + 0.5 Do While Timer < s DoEvents Loop End Function You could set it with an If...Then statement for control. I would say give it 10 seconds, then abort and try later. "Chris_In_Raleigh" wrote: Is there a way to do a 'timeout' on a line of code or a function. I have a VBA program that downloads files from our FTP server and software updates from websites and saves them to specific folders on our computers. This is used to keep everyone up to date on project files etc. The problem is that sometimes the program hangs on waiting for a response from the server. I have to close Excel from the task manager and start again. Is there a way to put a timeout on the execution of a function or line of VBA code. I guess this could help in the event that a function has an infinite Do...Loop in it by mistake, you could say if the value is not determined/returned after X amount of time, return an invalid value. |
All times are GMT +1. The time now is 02:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com