View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
BFSWE BFSWE is offline
external usenet poster
 
Posts: 9
Default Start a macro when a clock goes down to zero

Thanks Bernie.
I will try it tomorrow.
/Bo

"Bernie Deitrick" skrev:

You can use the ontime method. For example, the code below will play a sound for each of the
date/times listed in column A of the active sheet. (Just to give you an idea of how it is coded....)

HTH,
Bernie
MS Excel MVP

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub PlayWAV()
WAVFile = "C:\Program Files\Ahead\Nero\Trumpet1.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Sub SetAlarms()
Application.Calculate
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV"
Next myCell
End Sub

Sub CancelAlarms()
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV", , False
Next myCell
End Sub



"BFSWE" wrote in message
...
I am trying to make a macro work when a clock count down to zero. I have a
macro that is working when I am in some way activate the worksheet. How can I
activate the worksheet without doing a manual thing in it. I have a clock
running in the worksheet.
My macro looks like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("E29")
Case Is = 1
Range("E30").Select (This doesn´t happen before I do something
in the
End Select worksheet)

End Sub