Need macro to play sound in Excel 2007

Joined
Aug 10, 2010
Messages
1
Reaction score
0
Hello please help me, I need to make my macro push button play a sound after the user presses it. I have tried inserting the following:


Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub SoundWarning()
sndPlaySound32 "c:\windows\media\tada.wav", 0
End Sub

----------------------------------------------------------------------------
After inserting this I get the following error message:

Compile error: only comments may appear after end sub, end function, or end property

Here is what my code looks like:
Private Sub CommandButton1_Click()


Range("B23") = Range("B21") - Range("C21")
Range("B23").Select

Range("B25") = (Range("B14") / Range("C14"))

Range("B27") = 0.001 * (((Range("B3") * Range("B16") * Range("B17") * Range("B14") * 52) - (Range("C3") * Range("C17") * Range("C16") * Range("C14") * 52)))

Range("B29") = (Range("B7") / Range("B23"))

Range("B31") = (Range("B21") / Range("C21"))


End Sub

Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub SoundWarning()
sndPlaySound32 "c:\windows\media\tada.wav", 0
End Sub
--------------------------------------------------------------------------------

I am sorry for being such a big noob, thanks in advance for any help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top