Excel vba – make a beep sound

This has become a popular page in Google and my original notes on how to make a beep in VBA code did not work for everyone, so I have added some extra tips.

The basic code is:

——

sub make_a_beep()

beep

end sub

——-

Yes, it can be really that easy, but it does not work for everyone.   If it does not work the first place to check is that the system has a sound associated with the default, this is done by:

Control Panel ->  Hardware and Sound -> Change system sounds

(or just open the control panel window and search for change system sounds)

You need to have a speaker symbol next to Default Beep, as shown in the screen shot below.   if you don’t,  click on Default Beep and then select a sound from the drop down box below.

 

excel-beep-system-sound

If that still does not work you may have the system sounds turned off and sometimes you can get around this by enabling the system sound, as follows:

Sub test()
Application.EnableSound = True

Beep

Application.EnableSound = False

End Sub

 

If you want to play different types of beep depending on the condition have a look at the following

http://www.vbaexpress.com/kb/getarticle.php?kb_id=771

You can also play WAV files within a VBA macro but that looked a little more complex.  Search on “Excel VBA play wav file” and you will find several examples.

Good luck
Ian

Virtual Office

Telephone Answering Service

Comments are closed.