play sound

D

Dan D

Hello,

I have a spreadsheet that has some checkboxes. I want a
sound to play when the checkbox is clicked. How can I do
this?

Thanks
 
H

Harald Staff

Hi

Paste this in a module:

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

Sub PlayMe(OurSong As String)
Dim retval As Long
retval = PlaySound(OurSong, _
0, &H20000)
End Sub

And call it from the proper event, like

Private Sub CheckBox1_Click()
Call PlayMe("C:\Windows\media\1812Ouverture.wav")
End Sub
 
Top