Can sounds be played when cell value changes?

G

Guest

I was wondering if it is possible to play a wav file when the value of a cell
changes.
If so, how can I do this?
Any suggestions would help, thanks!
 
G

Guest

This should do it. In your worksheet place this code...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End If
End Sub

In a standard Code Module add this code...
'*******************************************
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function
'**************************************************
 
N

N10

Ruben said:
I was wondering if it is possible to play a wav file when the value of a
cell
changes.
If so, how can I do this?
Any suggestions would help, thanks!

Hi Ruben

You can also coax Excel to issue a vocal warning when the target cell
changes


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.Speech.Speak "The cell contents have changed"
End If
End Sub



Regards N10
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top