Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Halting Execution -- A Newbie Question (possible repeat, sorry)

Here is the code from my worksheet that continually queries the web for stock
quotes:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "GetData" ' the name of the procedure to run


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat,
Schedule:=True
End Sub



Sub GetData()
<functioning web query stuff here
StartTimer

End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat,
Schedule:=False
End Sub

Questions:
1. I have occasion to want to halt execution to update portions of the
workbook. I envision some sort of Pause and Resume code to do this. Ideas?
2. How do I modify this code to run only during business hours?

Many thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Halting Execution -- A Newbie Question (possible repeat, sorry)

You can not really just halt the code. What you can do however is have the
code check a global variable at run time to determine what it should do. If
the value of the global is true then run the GetData. If it is false then
just exit. This way all you need to do is to manipulate that variable to
change the way the code operates...

In short the code always runs, but it does not always do much depending on
the varaible...
--
HTH...

Jim Thomlinson


"John V" wrote:

Here is the code from my worksheet that continually queries the web for stock
quotes:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "GetData" ' the name of the procedure to run


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat,
Schedule:=True
End Sub



Sub GetData()
<functioning web query stuff here
StartTimer

End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedu=cRunWhat,
Schedule:=False
End Sub

Questions:
1. I have occasion to want to halt execution to update portions of the
workbook. I envision some sort of Pause and Resume code to do this. Ideas?
2. How do I modify this code to run only during business hours?

Many thanks.

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
Newbie Formula Question - how to get formula to repeat in each subsequent row? [email protected] New Users to Excel 2 January 10th 10 05:02 PM
Stopping Code Execution -- Newbie John V[_2_] Excel Programming 1 February 14th 08 12:51 AM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie repeat question Patrick[_14_] Excel Programming 4 August 16th 06 11:06 PM
code execution speed question Gary Keramidas Excel Programming 1 October 24th 05 09:05 PM


All times are GMT +1. The time now is 11:41 PM.

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"