assign a wav sound to a cell value

K

Kev

how do I assign a wav sound to a cell value?
I have a column with OR statements. when a cell in that column turns
TRUE, I want to hear a wav sound.
how can I do this?
 
K

Kev

that's very nice, Tom, but the one i (probably) need (the second link)
doesn't work. "Article is not Available" and i can't find it when
searching the MS Support website :(
 
T

Tom Ogilvy

Actually, using code like in the first article

'This function declaration must be entered onto a single line.
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub PlaySound()
If Application.CanPlaySounds Then
'Substitute the path and filename of the sound you want to play
Call sndPlaySound32("c:\win95\media\chimes.wav", 0)
End If
End Sub

place the above in a general module at the top

Then right click on the sheet tab and select view code.

in the left dropdown, select worksheet and in the right, calculate

Private Sub Worksheet_Calculate()

End Sub

will be placed in the module Add some code to this:

Private Sub Worksheet_Calculate()
if Application.countif(Range("A:A"),True) > 0 then
playsound
End if

End Sub


This assumes the true is produced by a formula. As long as a cell is true,
this would play the sound on every calculate. You would have to add code to
store values and make comparisons for it to be more discriminating.
 
Top