WAV FILE

G

Guest

how can i get a wav file to play in excel xp as an alarm when a value in a
particular cell has been exceeded?
 
G

Guest

Give this a try... If the value in Cell A1 on the sheet that this code is
placed in is change to anything greater than 100 then the wave file plays...

Option Explicit

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

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

Guest

Jim Thomlinson said:
Give this a try... If the value in Cell A1 on the sheet that this code is
placed in is change to anything greater than 100 then the wave file plays...

Option Explicit

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

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

i placed the code in the worksheet, changed the cell values, but it wont'
play a file!
i am new to programming in excel.
any help would be appreciated.

thanx,
bassfisher
 

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