Thread: WAV files
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David Overington[_2_] David Overington[_2_] is offline
external usenet poster
 
Posts: 3
Default WAV files

Perfect!
Many thanks, Leith, for the code and the clear layout.
Regards,
David

"Leith Ross" wrote in message
...
On Feb 3, 9:15 pm, "David Overington" wrote:
Is it possible to call up WAV files in Excel XP? I seem to recall this
was
easy in earlier versions but I can't find anything in VB help files.
Thanks.
David


Hello David,

You need to call an API to play a sound file. Here is the code. Change
the file path to the sound file you want to play in the macro
"PlaySoundFile". Load this into a Standard VBA module.

Start Macro
================================================== =======================================
Private Declare Function PlaySound _
Lib "winmm.dll" _
Alias "PlaySoundA" _
(ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Sub PlaySoundFile()

Dim Ret As Long
Const SND_SYNC As Long = &H0 'play synchronously (default)

Ret = PlaySound("C:\MyWavFile.wav", 0&, SND_SYNC)

End Sub

================================================== ====================================
End Macro

Sincerely,
Leith Ross