I have Excel 2000 and I try using this code from
http://www.j-walk.com/ss/excel/tips/tip87.htm
'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 & "sound.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function
The path of my wave file is:
C:WINNTMediaringout.wav
I replace in the above code as follows:
WAVFile = ThisWorkbook.Path & "C:WINNTMediaringout.wav"
but it doesn't play that sound. It plays like the default sound because it can't find the path for ringout. When running it, the sound card is not in use by any other program.
Thanks a lot for any help.
http://www.j-walk.com/ss/excel/tips/tip87.htm
'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 & "sound.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function
The path of my wave file is:
C:WINNTMediaringout.wav
I replace in the above code as follows:
WAVFile = ThisWorkbook.Path & "C:WINNTMediaringout.wav"
but it doesn't play that sound. It plays like the default sound because it can't find the path for ringout. When running it, the sound card is not in use by any other program.
Thanks a lot for any help.