Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Time remaining until event Highbury 1[_2_] Excel Discussion (Misc queries) 2 March 9th 09 02:57 PM
Calculate Ending time using Start Time and Elapsed Time Chief 711 Excel Worksheet Functions 5 May 13th 08 04:34 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 07:51 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"