How play a wav file

S

Scott

Is there a way to play a wav file, when a user does a
specific action? I've seen some code in the forum, but i
could not get it to work.

Thanks,

Scott
 
B

Bob Phillips

Hi Scott,

Here is some code to do it

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
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
S

Scott

Bob,

Thanks for the help. Works great!!!
-----Original Message-----
Hi Scott,

Here is some code to do it

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
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 
Top