TinaP
Well-known Member
- Joined
- Jan 26, 2005
- Messages
- 528
Is there a way to play a wma file via VBA in the background without having Windows Media Player take over? I'm trying to run a macro which starts a song and then macro proceeds to finish its job. Previously, I used the following code (from J-Walk's site), but it doesn't work in Excel 2007:
I'd rather not have Windows Media Player open up, if I can help it.
Code:
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Sub PlayWAV()
WAVFile = "dogbark.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
I'd rather not have Windows Media Player open up, if I can help it.