Add Sound to command button event




Need to have a sound bite play on click of a command button, a *.wav file or
similar. Anyone have any experience or guidence to a link for that
capability, having trouble getting into the MS Knowledge base areas tonight
for some reason.

Thanks for your assistance.



PC Datasheet

From my file ---

See below my SIG line.

PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)

Play A Sound In Any Event

To play a sound in any event, just set an event such as a form's OnOpen to:


Paste the following declaration and function into a module and save:

Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long

Function PlaySound(sWavFile As String)
' Purpose: Plays a sound.
' Argument: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function


May 31, 2017
Reaction score
how do you update this code for multiple buttons? I am working on a keyboard for a language and my client wants to be able to hear certain sounds when clicking specific keys. I have the keyboard built and I have the sounds needed.

But when I use this code all I get is the exclamation sound. I have coded each button I need but not even one button did anything except the exclamation sound. Is there a variation for multiple sounds on multiple buttons?

Please help, I have been stuck for days.

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

Similar Threads