Sounds on Excel

  • Thread starter Thread starter David Harrison
  • Start date Start date
D

David Harrison

This may not be a feature of excel but if anyone can help
me i woul be very greatful!!!!

I have a list box where i choose a certain status. E.G.

CGC
NFA
GHE
HST
JYT
and i also have 118.

Would there be any way in which i can have a sound or
noise come on when i press 118. also would i be able to
have the numbers 118 flash while on screen.

I know this is not your every day question but it would
be a really good feature.

Many Thanks

David Harrison
 
Hi David

In a standard module (VB Editor opened by Alt F11 or equivalent, Insert > Module):

Option Explicit

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

Sub SongAndDance(WhichOne As String)
Dim retval As Long
retval = PlaySound("C:\Windows\media\" & WhichOne, _
0, &H20000)
End Sub

And in the moduleof the thing where your listbox resides; userform, sheet, wherever:

Private Sub ListBox1_Click()
If ListBox1.Text = "118" Then
Call SongAndDance("Tada.wav")
Else
Call SongAndDance("Ding.wav")
End If
End Sub
 
Oops, sorry. Forgot:
No flashing. It would not be a really good feature. It would be awful. And Excel doesn't
support flashing, so I guess she agrees.
 
Back
Top