Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
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
Detecting the actual playing or NOT playing of a WAV file Bajbaj Excel Discussion (Misc queries) 0 October 24th 07 09:16 PM
How do I keep the ding sound from playing when a message appears? Quinn1984 Excel Discussion (Misc queries) 2 September 12th 07 01:04 PM
Playing a sound file from entry in cell NG99 Excel Discussion (Misc queries) 2 January 31st 07 12:27 AM
Help Playing a sound if a cell's value chjanges as a result of a calculation Syd Excel Discussion (Misc queries) 1 September 2nd 06 01:36 AM
Playing Vedio clip in excel cell Jagz Excel Discussion (Misc queries) 1 January 1st 05 11:16 AM


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