Play Audio File using Excel VBA / Excel VBA Play Wav File
Here is a small snippet used by Pradeep Meesala to play a wav file. He has used this for an elegant splash screen, which was a nice combination of music and display
The code uses PlaySound API Function
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Sub Play_Wav_File()
Dim sWAVFile As String
On Error GoTo Err_Play
sWAVFile = "C:\Temp\Windows XP Logon Sound.wav"
PlaySound(sWAVFile, &O0, 0)
Err_Play:
If Err <> 0 Then
Err.Clear()
End If
End Sub
I get a compile error at this code snipet . It says only comments may appear after End Sub, End Function, or End Property ??? Help
ReplyDeletePrivate Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
I get compile error when I try this on Excel 2007
ReplyDeleteI believe it should be inserted at the start of a module after any option statements but before any procedures
ReplyDeleteDoesn't work for me no matter what I do.
ReplyDeleteI've been using for years and have had no issues. you need to insert it before you start a sub
ReplyDelete