MrExcel Publishing
Your One Stop for Excel Tips & Solutions


Posted by david on July 25, 2000 10:15 PM

Anyway to put a beep in or a sound through a macro or data validation. Just kind of like an error note to get your attention but with sound.

Posted by Ivan Moala on July 26, 0100 1:34 AM

Just add a Beep command to your routine.
Look up Beep in online help.

To play a sound file you can do one of 2 things
1) insert a wave file on your work sheet and
play around with macro recording & double
2) Play a file ;

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Private Declare Function Playsound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Sub PlayWav()
Dim WAVFile As String
WAVFile = "The Microsoft sound.wav"
WAVFile = "C:\windows\media\" & WAVFile
MsgBox "Play sound now?"
Call Playsound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
MsgBox "sound is playing asynchronously"
End Sub