Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
background commands running in Excel? | Excel Discussion (Misc queries) | |||
Find %ontime & SUMIF ontime ie: find matching sets within Range... | Excel Worksheet Functions | |||
How do I restore excel running in the background? | Excel Discussion (Misc queries) | |||
Running Excel as a batch job AND in the background | Excel Programming | |||
OnTime running 2 subs | Excel Programming |