Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default onTime loop running in the background

Im having a little bit of trouble figuring out how to have an onTime
loop (for example, having it call a procedure every 10 seconds) run in
the background. It's important to remain in the background because the
user needs to be able to continue to write to a dialog box, or select
options on the page . Thanks,
Ben


---
Message posted from
http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default onTime loop running in the background

Bdcrisp wrote:
Im having a little bit of trouble figuring out how to have an onTime
loop (for example, having it call a procedure every 10 seconds) run in
the background. It's important to remain in the background because the
user needs to be able to continue to write to a dialog box, or select
options on the page .


Your macro will only run after other macro activity finishes, and if
Excel is not in Edit mode. You can be using a non-modal userform (Excel
2000 and later). The code would be something like this

Dim NextTime As Date

Sub Auto_Open()
StartEvent
End Sub

Sub Auto_Close()
StopEvent
End Sub

Sub StartEvent()
NextTime = Now+TimeValue("00:00:10")
Application.OnTime NextTime, "DoEvent"
End Sub

Sub StopEvent()
If NextTime<0 Then
Application.OnTime NextTime, "DoEvent", schedule:=False
NextTime = 0
End If
End Sub

Sub DoEvent()
' whatever you want to do and then
StartEvent ' set another one to run
End Sub




Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default onTime loop running in the background

So is it impossible to have a timed procedure call while the user is
editing the page? Basically, i am trying to set up a loop that
periodically checks the filelen of a text file. If the filesize is
different than the value from the previous check, the contents of a
certain text box (text box A) is updated. During this time, the user
should still be able to edit the worksheet (write to a different text
box (text box B), or just sit and look as the contents of text box A
are refreshed.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default onTime loop running in the background

Bdcrisp wrote:
So is it impossible to have a timed procedure call while the user is
editing the page?


That is correct.

The execution of the procedure will be delayed until the user stops
editing the cell. Editing the content of a Control Toolbox textbox
will not delay the procedure execution.


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default onTime loop running in the background

oh ok, yes thanks. I've been using ole controls for the editing..
however. No matter how hard i try .. when the user closes the file i
always asks to reopen the file.. the ontime command has something to d
with that.. ive tried to shutdown the timer but it doesnt seem to work

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default onTime loop running in the background

See chip Pearson's site:
http://www.cpearson.com/excel/ontime.htm

--
Regards,
Tom Ogilvy

bdcrisp wrote in message
...
oh ok, yes thanks. I've been using ole controls for the editing...
however. No matter how hard i try .. when the user closes the file it
always asks to reopen the file.. the ontime command has something to do
with that.. ive tried to shutdown the timer but it doesnt seem to work.


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default onTime loop running in the background

Bdcrisp wrote:
No matter how hard i try .. when the user closes the file it
always asks to reopen the file.. the ontime command has something to do
with that.. ive tried to shutdown the timer but it doesnt seem to work.


If you use my code (earlier in the thread) as a model you should avoid
this - as long as you only start one sequence of events. While debugging
this can be difficult to achieve (if you reset the project you lose the
value of dNextTime and so can't use it to cancel the next event).
You could overcome this by using a worksheet cell instead of a VBA
variable to hold the next scheduled time. Or just make sure to exit from
Excel when closing the file.




Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default onTime loop running in the background

i was attempting this ontime loop as part of a network chat program that
i wrote. i've finally gotten it to work correctly.. kinda neat.

it basically reads and writes (user info/ messages) to a text file
located in a shared folder, then updates the client book's chat window
if, during this timed loop, it finds that the filesize of the chatlog
has changed.

Would you try it out and tell me how it works (if you have access to
network) ?
when you download first time, open w macros disabled, goto the 2nd
sheet and change the chatlog/userlog path to point to the common shared
folder on your network., save, close, and reopen with macros enabled.
Here's the link:


http://home.doramail.com/benssamples:doramail.com/


---
Message posted from http://www.ExcelForum.com/

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
background commands running in Excel? AnalystMark Excel Discussion (Misc queries) 1 January 26th 10 05:42 PM
Find %ontime & SUMIF ontime ie: find matching sets within Range... Chris T-M Excel Worksheet Functions 3 October 10th 08 08:14 PM
How do I restore excel running in the background? BillS Excel Discussion (Misc queries) 0 August 31st 06 08:26 PM
Running Excel as a batch job AND in the background GB[_3_] Excel Programming 0 August 30th 03 01:08 PM
OnTime running 2 subs Martin Wheeler Excel Programming 3 August 23rd 03 07:10 PM


All times are GMT +1. The time now is 07:18 PM.

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

About Us

"It's about Microsoft Excel"