ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I use VBA to play a WAV file? (https://www.excelbanter.com/excel-programming/370462-can-i-use-vba-play-wav-file.html)

Conan Kelly

Can I use VBA to play a WAV file?
 
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).

--
Thanks for any help anyone can provide,

Conan Kelly



Norman Jones

Can I use VBA to play a WAV file?
 
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


---
Regards,
Norman



Bob Phillips

Can I use VBA to play a WAV file?
 
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" <CTBarbarin at msn dot com wrote in message
...
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).

--
Thanks for any help anyone can provide,

Conan Kelly






All times are GMT +1. The time now is 01:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com