Can I use VBA to play a WAV file?

  • Thread starter Thread starter Conan Kelly
  • Start date Start date
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).
 
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
 
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).
 
Back
Top