How do I play a .wav file with VB.

Microsoft Office excel 2007 home & stude...
March 16, 2011 at 14:25:15
Specs: Windows XP
How can I use VB to play a .wav file when another program maximizes?

See More: How do I play a .wav file with VB.

Report •

May 17, 2011 at 02:50:28
You an use the below code to play a sound, you can pass the path of the file to the sub below.

now to play the sound when another program maximies, what i will do is get that programs handle and continously tests its window state and if maximised then plausound.

Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

Public Sub PlaySound(FileName As String)
Dim SoundName As String
Dim nFlag As Long
Dim PlayThis As Long

SoundName = FileName

PlayThis = sndPlaySound(SoundName, nFlag)

End Sub

Report •
Related Solutions

Ask Question