Quote from traderNik:
Joined the Excel Experts Club at Yahoo groups, maybe they can help me out in there.
Here is a complete sample of the windows Declare function for the VBA Timer event and the VBA code itself in three parts...
GIVE THIS TO A YAHOO GUY/GROUP WHO WANTS TO HELP YOU...
What it can do is test a spreadsheet for price changes every whatever (x) seconds... and you can also have the VBA coder set off a wave file audio alert too... .mdw file
Declares
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
VBA Timer Code...
Sub StartTimer ()
On Error GoTo Err_Prob
TimerSeconds = 2 'pop the windows time every x seconds
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
Exit_Err_Prob:
Exit Sub
Err_Prob:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Err_Prob
End Sub
Sub EndTimer()
On Error GoTo Err_Prob
runTimer = False
KillTimer 0&, TimerID
Exit_Err_Prob:
Exit Sub
Err_Prob:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Err_Prob
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
HAVE THE YAHOO GUY/GROUP DO THEIR CODE HERE TO TEST YOUR SYMBOLS FOR THE LAST PRICE VALUE...
THAT IS QUITE EASY FOR EXCEL VBA CODER.
'you also need error handling since pulling and pushing data burps once in awhile...
Exit_Err_Prob:
Exit Sub
Err_Prob:
If Err.Number = 55 Then
'take some code action here...
Resume Next
Else
Err.Clear ' Clear Err object fields
Resume Next
MsgBox Err.Description
End If
If Err.Number = 440 Or Err.Number = 432 Then
'Tell user what happened. Then clear the Err object.
MsgBox "There was an error attempting to open the Automation object!"
Err.Clear ' Clear Err object fields
Resume Next
End If
EndTimer
StartTimer
Debug.Print Err.Number & " " & Err.Description
Resume Exit_Err_Prob
End Sub
You build a macro button on the front interface of Excel that calls the start timer event and a button that does the End Timer event and -- bada bing... you got a timing system...
<img src="http://www.enflow.com/p.gif">