Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
I am trying to program an alarm like this:
Sub SetAlarm() Application.OnTime TimeValue("12:12:00 pm"), "DisplayAlarm" End Sub Sub DisplayAlarm() Beep MsgBox "Wake up. Its time for your afternoon break!" End Sub However it never seems to go off. I have put in a regular module. What have I done wrong? Thank-yo -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
In order for the application to check the time SetAlarm() has to b
running. If you start SetAlarm() you can have it WAIT until that time but that probably won't work for you. Search the newsgroup and yo should find several explanations of how to do exactly what you'r asking about. - Piku -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
ExcelM,
Here is another example and it works. Sub SetAlarm() Application.OnTime Now + TimeValue("00:01:00"), "DisplayAlarm" End Sub Sub DisplayAlarm() Beep MsgBox "Wake up. Its time for your afternoon break!" End Sub Charle -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
The reason it wasn't working is that I did not run it. I forgot it wa
in a module which actually needs to RUN. I was sitting there waitin for it to engage like a dummay!!!!! Yes Charles yours works too WHEN RUN. Thanks -- Message posted from http://www.ExcelForum.com |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
SetAlarm doesn't have to be running for this to work. It has to have been
run one time to set the event. Sub SetAlarm() Application.OnTime TimeValue("2:43:00 pm"), "DisplayAlarm" End Sub Sub DisplayAlarm() Beep MsgBox "Wake up. Its time for your afternoon break!" End Sub worked fine for me. If Excel had the focus the message pop'd up in the foreground If Excel did not have the focus, the Excel icon on the taskbar turned blue and pulsed. Activating excel revealed the message pop'd up. Excel 2000, Windows 2000 -- Regards, Tom Ogilvy "pikus " wrote in message ... In order for the application to check the time SetAlarm() has to be running. If you start SetAlarm() you can have it WAIT until that time, but that probably won't work for you. Search the newsgroup and you should find several explanations of how to do exactly what you're asking about. - Pikus --- Message posted from http://www.ExcelForum.com/ |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
Another question. What if I wanted this to run every minute. The cod
below when ran will excute once i.e. 1 minute after NOW. However i does not run again. In order to dot this, do I have to make th SetAlarm sub call itself befor the EndSub line (i.e. recursiv programming)? Thanks Sub SetAlarm() Application.OnTime Now + TimeValue("00:01:00"), "DisplayAlarm" End Sub Sub DisplayAlarm() Beep MsgBox "Wake up. Its time for your afternoon break!" End Su -- Message posted from http://www.ExcelForum.com |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
See www.cpearson.com/excel/ontime.htm for example code.
-- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "ExcelMonkey " wrote in message ... Another question. What if I wanted this to run every minute. The code below when ran will excute once i.e. 1 minute after NOW. However it does not run again. In order to dot this, do I have to make the SetAlarm sub call itself befor the EndSub line (i.e. recursive programming)? Thanks Sub SetAlarm() Application.OnTime Now + TimeValue("00:01:00"), "DisplayAlarm" End Sub Sub DisplayAlarm() Beep MsgBox "Wake up. Its time for your afternoon break!" End Sub --- Message posted from http://www.ExcelForum.com/ |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
So Chip, I used teh following code from your site. But it only ran onc
as opposed to every minute. Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' one minute Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Sub The_Sub() MsgBox "Wake up. Its time for your afternoon break!" End Su -- Message posted from http://www.ExcelForum.com |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
Public RunWhen As Double
Public Const cRunIntervalSeconds = 60 ' one minute Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Sub The_Sub() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True MsgBox "Wake up. Its time for your afternoon break!" End Sub Sub StopIt() Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=False End Sub -- Regards, Tom Ogilvy "ExcelMonkey " wrote in message ... So Chip, I used teh following code from your site. But it only ran once as opposed to every minute. Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' one minute Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Sub The_Sub() MsgBox "Wake up. Its time for your afternoon break!" End Sub --- Message posted from http://www.ExcelForum.com/ |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
You need to set RunWhen and then call OnTime from within The_Sub.
"ExcelMonkey " wrote in message ... So Chip, I used teh following code from your site. But it only ran once as opposed to every minute. Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' one minute Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Sub The_Sub() MsgBox "Wake up. Its time for your afternoon break!" End Sub --- Message posted from http://www.ExcelForum.com/ |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
On time Event
thanks Tom. I guess I could call the StartTimer sub again at the end o
the final sum too. Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' one minute Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Sub The_Sub() MsgBox "Wake up. Its time for your afternoon break!" StartTimer End Su -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Time remaining until event | Excel Discussion (Misc queries) | |||
Calculate Ending time using Start Time and Elapsed Time | Excel Worksheet Functions | |||
Event Procedures: Event on Worksheet to fire Event on another Worksheet | Excel Programming | |||
change event/after update event?? | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |