Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Recursive Functio help BigBobbo Excel Worksheet Functions 1 May 10th 06 07:23 PM
Using and IF functio between 2 worksheets. Mike Excel Worksheet Functions 4 January 8th 06 07:34 PM
TImeIn-TimeOut-TimeIn-TimeOut-HoursWorked ChefBoiRD Excel Worksheet Functions 3 September 20th 05 10:01 AM
Editing recorded macro code. Referencing workbook name in functio Mark Excel Programming 2 April 6th 05 11:03 PM


All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"