Article ID: 170730
Article Last Modified on 1/20/2007
Private Declare Function sndPlaySound Lib "winmm.dll" Alias _ "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags _
As Long) As Long
Private Declare Function GetWindowsDirectoryA Lib "Kernel32" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
Sub PlayWav()
Dim sBuf As String
Dim cSize As Long
Dim retval As Long
Dim Windir As String
'Create a variable large enough to store the Windows path.
sBuf = String(255, 0)
cSize = 255
'Get Windows Directory
retval = GetWindowsDirectoryA(sBuf, cSize)
'Strip buffer from Windows directory
Windir = Left(sBuf, retval)
'Load and Play the sound.
N = sndPlaySound(Windir + "\Media\Chimes.wav", 0)
End Sub
Additional query words: 8.0 vb vba vbe offcon wordcon
Keywords: kbdtacode kbhowto kbmacro kbprogramming kbsound KB170730