Need macro to play sound in Excel 2007

G

Gary''s Student

Assign the button to something like:

Sub Macro1()
x = Shell("cmd.exe /c C:\destiny.wav", 1)
End Sub
 
A

AL

Thanks for responding. Unless I did something wrong, this did not work. I
created a form with a single button. The button click performed your
recommended code. I replaced "destiny.wav" with my own wav file but it still
did not work. Again, thanks.

AL
 
H

Homey

maybe better not use shell

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

| Thanks for responding. Unless I did something wrong, this did not work.
I
| created a form with a single button. The button click performed your
| recommended code. I replaced "destiny.wav" with my own wav file but it
still
| did not work. Again, thanks.
|
| AL
|
|
|
| "Gary''s Student" wrote:
|
| > Assign the button to something like:
| >
| > Sub Macro1()
| > x = Shell("cmd.exe /c C:\destiny.wav", 1)
| > End Sub
| > --
| > Gary''s Student - gsnu200848
| >
| >
| > "AL" wrote:
| >
| > > When a user button is pushed, how to I play a sound clip (like a wav
file)?
 

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