Can I use VBA to play a WAV file?

C

Conan Kelly

Hello all,

Can I use VBA to play a WAV file or some other sound file format? I do not want the playing of this sound to open up an external
media player and be played inside of it, I want it to be a sound that just plays (like Windows and other programs events sounds).
 
N

Norman Jones

Hi Conan,

'------------------------
Can I use VBA to play a WAV file or some other sound file format?
I do not want the playing of this sound to open up an external
media player and be played inside of it, I want it to be a sound that just
plays (like Windows and other programs events sounds).

'------------------------

See John Walkenbach at:

http://www.j-walk.com/ss/excel/tips/tip87.htm
 
B

Bob Phillips

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


Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


call it like


PlayWavFile ("C:\Windows\Media\Microsoft Office 2000\Chimes.wav")


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Conan Kelly said:
Hello all,

Can I use VBA to play a WAV file or some other sound file format? I do
not want the playing of this sound to open up an external
media player and be played inside of it, I want it to be a sound that just
plays (like Windows and other programs events sounds).
 

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