Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Playing a sound base on cell value
Hello all,
I have an excel sheet that updates every 2 seconds from an SQL server that is fed by a PLC. I am monitoring the speed of a manufacturing line. I want a wave file to play if the line stops (cell value=0). I found the code for calling sounds, but how do I get it to play once, after the cell equals 0? I assume the code would be similar to play a different sound when the line starts back up again? Windows 2000 Excel 2000 Thanks, Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Playing a sound base on cell value
You might consider declaring a global variable in your module that contains
the reference of the last cell on which your code beeped. Then, in your sub, check to see if it's trying to beep on the same cell. If it is the same cell, just skip the beep. If not, beep, and then set the variable to the current cell on which it's beeping. For something specific to your code, post your code. /i. "Mike" wrote in message ... Hello all, I have an excel sheet that updates every 2 seconds from an SQL server that is fed by a PLC. I am monitoring the speed of a manufacturing line. I want a wave file to play if the line stops (cell value=0). I found the code for calling sounds, but how do I get it to play once, after the cell equals 0? I assume the code would be similar to play a different sound when the line starts back up again? Windows 2000 Excel 2000 Thanks, Mike |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Playing a sound base on cell value
Mike,
Take a look he http://j-walk.com/ss/excel/tips/tip87.htm John "Mike" wrote in message ... Hello all, I have an excel sheet that updates every 2 seconds from an SQL server that is fed by a PLC. I am monitoring the speed of a manufacturing line. I want a wave file to play if the line stops (cell value=0). I found the code for calling sounds, but how do I get it to play once, after the cell equals 0? I assume the code would be similar to play a different sound when the line starts back up again? Windows 2000 Excel 2000 Thanks, Mike |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Playing a sound base on cell value
John,
Thanks a bunch. I've been through the tips on JW's site and only remember the generic sound tip. Thanks for the redirect, Mike -----Original Message----- Mike, Take a look he http://j-walk.com/ss/excel/tips/tip87.htm John "Mike" wrote in message ... Hello all, I have an excel sheet that updates every 2 seconds from an SQL server that is fed by a PLC. I am monitoring the speed of a manufacturing line. I want a wave file to play if the line stops (cell value=0). I found the code for calling sounds, but how do I get it to play once, after the cell equals 0? I assume the code would be similar to play a different sound when the line starts back up again? Windows 2000 Excel 2000 Thanks, Mike . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Playing a sound base on cell value
-----Original Message----- You might consider declaring a global variable in your module that contains the reference of the last cell on which your code beeped. Then, in your sub, check to see if it's trying to beep on the same cell. If it is the same cell, just skip the beep. If not, beep, and then set the variable to the current cell on which it's beeping. For something specific to your code, post your code. /i. "Mike" wrote in message ... Hello all, I have an excel sheet that updates every 2 seconds from an SQL server that is fed by a PLC. I am monitoring the speed of a manufacturing line. I want a wave file to play if the line stops (cell value=0). I found the code for calling sounds, but how do I get it to play once, after the cell equals 0? I assume the code would be similar to play a different sound when the line starts back up again? Windows 2000 Excel 2000 Thanks, Mike . '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 is =Alarm(A3,"D2=0") |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Detecting the actual playing or NOT playing of a WAV file | Excel Discussion (Misc queries) | |||
How do I keep the ding sound from playing when a message appears? | Excel Discussion (Misc queries) | |||
Playing a sound file from entry in cell | Excel Discussion (Misc queries) | |||
Help Playing a sound if a cell's value chjanges as a result of a calculation | Excel Discussion (Misc queries) | |||
Playing Vedio clip in excel cell | Excel Discussion (Misc queries) |