VBA Excel - Generating Sounds

  • Thread starter Thread starter ajliaks
  • Start date Start date
A

ajliaks

Hi all,

Could anybody tell me how to generate a sound?

I need to play a sound every time I finish running a macro.

Thanks in advance,
Aldo
 
Hi ajliaks, I use this code, just put the sound file in the same folder/
directory and call it by the macro and it should work...


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 playmywavfile()
WAVFile = "thewavyouwanttoplay.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

hope this helps...

seeya ste
 

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