WAV files

  • Thread starter Thread starter David Overington
  • Start date Start date
D

David Overington

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
 
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
 
Perfect!
Many thanks, Leith, for the code and the clear layout.
Regards,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top