Function to return sound?

  • Thread starter Thread starter gifer
  • Start date Start date
G

gifer

I have a file that is monitoring and trending external data. I have a type
of animation that occurs based on the data (very simple graphics using
fonts, colors and conditional formating). Similarly, I have tables that have
cells changing colors to reflect the type of value in the cell based on a
range criteria.

Rather than using conditional formating to return a color or some
traditional format, I want to know how to execute a MS sound, or in some
way, launch a macro, etc., where a sound could be driven. Any MS sound would
be fine. I just can think of a way similar to conditioinal formating, where
a value meeting a criteria can drive some other event beyond what we
typically have avaliable in the Fx that excel comes with.

I'm not a big macro programer, but am always willing to learn something new!

Any ideas?

Thanks!

John
 
John,

You can play a sound from a macro with sndPlaysound:

Public Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal udFlags As Long) As Long

Sub TestPlayWavFile()
SoundFile = "c:\audio\dinner with drac.wav"
sndPlaySound SoundFile, 1
End Sub

You'll need a regular .wav sound file. There are plenty of those all
around.

Just so you'll know, post in only one group. This prevents redundant effort
on the part of the responders.
 
Hi John,
Here is a Change Event macro. To install right click on the worksheet tab,
view code, and insert the following code after the option statement.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
On Error Resume Next
If Target.Value = 14 Then
Beep
End If
End Sub

It will beep if you enter a 14 into any cell in column A.
More on event macros in

Event Macros, Worksheet Events and Workbook Events
http://www.mvps.org/dmcritchie/excel/event.htm
 
Back
Top