Gil
04-27-2010, 01:38 PM
Hello
I want to be able to play a .wav sound file when a userform is opened. The following code works ok when you enter your own file path etc. I have entered the code in a module and all works ok manually but I can't get it to work automatically when the userform opens.
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_FILENAME As Long = &H20000
Private Sub Knock_Click()
PlaySound "C:\Knock.wav", 0&, SND_FILENAME
'/// where "C:\Knock.wav" gets replaced by your wav's path / name.
End Sub
All suggestions gratefully received.
Gil
I want to be able to play a .wav sound file when a userform is opened. The following code works ok when you enter your own file path etc. I have entered the code in a module and all works ok manually but I can't get it to work automatically when the userform opens.
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_FILENAME As Long = &H20000
Private Sub Knock_Click()
PlaySound "C:\Knock.wav", 0&, SND_FILENAME
'/// where "C:\Knock.wav" gets replaced by your wav's path / name.
End Sub
All suggestions gratefully received.
Gil