Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Alarm Sound Function Not Working_Any DDE Gurus??

I have been trying to set up a spdsht that will compare the previous
10 day volume with the current volume. this is compared by 30 minute
increments. for example i am comparing the volume traded from 10am-
10:30am EST with the previous 10 Days at the same time period (10-
10:30am).
What i have is an alarm that goes off when todays volume exceeds the
prev 10 day average. i want to be able to have is :

1. the alarm sounds when todays volume exceeds prev 10 Day
2. Have a "stop sound" button or "reset" button that stops
the alarm for that 30 Min period, but will continue to
update after the 30 interval is complete.


This is the code that i have so far in my module:
///////////////////////////////////////////////////////
'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long


Function alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler

If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\buy.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
alarm = True
Exit Function
End If

ErrHandler:
alarm = False
End Function
/////////////////////////////////////////////////////////
Public Sub SoundBeep()
If Range("I7") = "True" Then
ActiveCell.Range("I7") = "=IF(RC[-3]RC[-1],alarm(RC[-
3],""H7"")"
Else
If Range("I7") = "False" Then
alarm "I7", "=0"
End If

End If
End Sub
////////////////////////////////////////////////////////////

This is the code i have in Sheet 3

Dim intResult As Integer

Private Sub CommandButton01_Click()
intResult = PlaySound(vbNullString, vbNull, SND_NODEFAULT)

End Sub
///////////////////////////////////////////////////////////

If anyone would like better clarification on any specifics please
contact me or message me. I would really appreciate some help from
those that really enjoy the nitty gitty about XL.
Thanks very much

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Alarm Sound Function Not Working_Any DDE Gurus??

Hi
one question regarding your 'stop button' where should this button be:
- should you get a messagebox if the alarm was issued and you can
decide whether to stop or not (this will work on individual cell base)
- do you want a global 'Stop button'?

For the first one you may try the following: Replace the alarm function
with the following adapted version:

Function alarm(Cell, Condition)
Static cond(30, 30)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Dim ret_value
On Error GoTo ErrHandler

If Evaluate(Cell.Value & Condition) Then
If cond(Cell.row, Cell.Column) < Now Or cond(Cell.row, Cell.Column)
= "" Then
cond(Cell.row, Cell.Column) = ""
WAVFile = ThisWorkbook.path & "\buy.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)

ret_value = MsgBox("Alarm - Stop for 30 minutes?", vbYesNo)
If ret_value = 6 Then
cond(Cell.row, Cell.Column) = Now + TimeValue("00:30:00")
End If
alarm = True
Exit Function
Else
' do nothing
End If
End If

ErrHandler:
alarm = False
End Function

------
Note: I declared a static array with the a dimension of 30 rows/30
columns. You may have to adapt this if you have your alarm cell for
example in A100



--
Regards
Frank Kabel
Frankfurt, Germany

I have been trying to set up a spdsht that will compare the previous
10 day volume with the current volume. this is compared by 30 minute
increments. for example i am comparing the volume traded from 10am-
10:30am EST with the previous 10 Days at the same time period (10-
10:30am).
What i have is an alarm that goes off when todays volume exceeds the
prev 10 day average. i want to be able to have is :

1. the alarm sounds when todays volume exceeds prev 10 Day
2. Have a "stop sound" button or "reset" button that stops
the alarm for that 30 Min period, but will continue to
update after the 30 interval is complete.


This is the code that i have so far in my module:
///////////////////////////////////////////////////////
'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long


Function alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler

If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\buy.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
alarm = True
Exit Function
End If

ErrHandler:
alarm = False
End Function
/////////////////////////////////////////////////////////
Public Sub SoundBeep()
If Range("I7") = "True" Then
ActiveCell.Range("I7") = "=IF(RC[-3]RC[-1],alarm(RC[-
3],""H7"")"
Else
If Range("I7") = "False" Then
alarm "I7", "=0"
End If

End If
End Sub
////////////////////////////////////////////////////////////

This is the code i have in Sheet 3

Dim intResult As Integer

Private Sub CommandButton01_Click()
intResult = PlaySound(vbNullString, vbNull, SND_NODEFAULT)

End Sub
///////////////////////////////////////////////////////////

If anyone would like better clarification on any specifics please
contact me or message me. I would really appreciate some help from
those that really enjoy the nitty gitty about XL.
Thanks very much.


---
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
Alarm function, disable sound if data is erased offdah3z Excel Worksheet Functions 1 July 21st 09 08:13 PM
Excel Gurus-Please Help! Ginny Excel Discussion (Misc queries) 1 November 1st 07 05:22 PM
CAN EXCELL SOUND AN ALARM ? DWATERS Excel Discussion (Misc queries) 2 February 1st 07 10:17 PM
Should be an easy one for you Gurus... Jennifer Carr New Users to Excel 3 July 28th 05 06:28 PM
How does Excel Alarm Function work?? joeshow Excel Programming 4 March 5th 04 05:46 PM


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