Playing Sounds

Ever wanted to play a sound to warn users or congratulate them? You could add a sound object to a sheet and call that, but it would be much easier just to use the following API declaration and specify the proper path to a sound file:

Public Declare Function PlayWavSound Lib "winmm.dll" _ Alias "sndPlaySoundA" (ByVal LpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub PlaySound() Dim SoundName As String

SoundName = "C:\WinNT\Media\Chimes.wav" PlayWavSound SoundName, 0

End Sub

0 0

Post a comment