Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Follow up with sound question- need more help

Hello all,

A few days ago I asked for help playing a sound based on a
cell value. I was pointed to John Walkenbach's site that
did just that. In my case it needs tweaked a bit. It
plays over and over- I believe due to the fact the sheet
is continuously updating. I only need it to play once and
not play again until the cell value goes back to 0 and
starts up again. Here's what I have:

'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 & "\go.wav" 'Edit this
statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or
SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function

Function =Alarm(D2,"0")

I want it to play "go.wav" "once" when it is greater than
zero. The cell D2 represents a manufacturing line speed. I
want to know went it starts. My sheet refreshes every 2
secs pulling from a server which is fed by a PLC. After
it starts and gets up to speed at about 600 or so, it
fluctuates on almost every refresh. This causes the sound
file to play over and over. Any help would be appreciated.

Thanks, Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Follow up with sound question- need more help


-----Original Message-----
Hello all,

A few days ago I asked for help playing a sound based on

a
cell value. I was pointed to John Walkenbach's site that
did just that. In my case it needs tweaked a bit. It
plays over and over- I believe due to the fact the sheet
is continuously updating. I only need it to play once and
not play again until the cell value goes back to 0 and
starts up again. Here's what I have:

'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 & "\go.wav" 'Edit

this
statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or
SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function

Function =Alarm(D2,"0")

I want it to play "go.wav" "once" when it is greater than
zero. The cell D2 represents a manufacturing line speed.

I
want to know went it starts. My sheet refreshes every 2
secs pulling from a server which is fed by a PLC. After
it starts and gets up to speed at about 600 or so, it
fluctuates on almost every refresh. This causes the sound
file to play over and over. Any help would be

appreciated.

Thanks, Mike


I thought about it some more and a simple answer came to
me. I'll just set a second cell value to 1 if D20 and
read the function off the second cell. Then the
fluctuations won't cause the sound file to repeat. Duh!


Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Follow up with sound question- need more help


It's not the fluctuations that cause the replay it's the
sheet refresh. Back to square one.

Mike
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
Follow Up Macro Question MrAcquire Excel Discussion (Misc queries) 4 February 12th 10 04:55 PM
Follow up Question to Countif Ajay Excel Discussion (Misc queries) 4 February 16th 09 06:22 PM
A follow up Question Andrew Mackenzie Excel Discussion (Misc queries) 4 November 17th 08 02:50 PM
Follow-up AVERAGEIF question Ken[_3_] New Users to Excel 2 April 11th 08 05:45 PM
Follow-Up (Clarification) to MIN question Odawg Excel Discussion (Misc queries) 4 October 20th 05 04:04 AM


All times are GMT +1. The time now is 03:20 AM.

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"