Quote from aweissen:
Take a look at Edgehunter's post:
http://www.elitetrader.com/vb/showthread.php?s=&threadid=54894&perpage=6&pagenumber=394
which should get you headed in the right direction.
You need the following things to fire off a sound if the value of a cell hits your target...
The first is a timer event that is continuously running (once you start it) in excel called by a click on a macro button on the menu bar...
you create a timer event with an api call in your VB area... and then add the timer event code and then run it with the macor button mentioned above
here is the declaration and the variables and the timer start event, the timer end event and the timer event itself which has the play sound event in it...
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
third to play that sound you need to call an api sound function in your VB... which is also added above which a function that is inside your continuously running timer event... which checks your volume every whatever seconds...
Sub StartTimer()
TimerSeconds = 10 'pop the windows time every x seconds
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
runTimer = False
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error GoTo Err_Prob
'pseudo code...
If Cell X value = 200000 then
PlaySound ("c:\WINNT\Media\notify.wav")
Else
'Do nuthin
End If
Exit_Err_Prob:
Exit Sub
Err_Prob:
EndTimer
End Sub
here is code that makes the sound that is called from the timer event
Function PlaySound(sWavFile As String)
' Purpose: Plays a sound.
' Argument: the full path and file name.
End Function
you can also call the -timer end event- when you want to not check the volume value with a similar macro button on the menu bar that says end time and when click calls the end timer event
cj...
HtHs
__________________
HAVE STOP - WILL TRADE
If You Have The Vision We Have The Code