Alert Function May Not Beep (107137)



The information in this article applies to:

  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0

This article was previously published under Q107137

SUMMARY

In Microsoft Excel versions earlier than 5.0, the ALERT() macro function automatically causes the computer to beep. In Microsoft Excel versions 5.0 and 7.0, the computer does not automatically beep when you use the ALERT() macro function or the Visual Basic MsgBox function.

MORE INFORMATION

Microsoft Excel version 5.0 does not automatically beep when an ALERT() box or MsgBox is displayed. This allows you to determine what sound (if any) you want to be played when a message box is displayed.

If you do want to hear a beep sound, you must use the BEEP() function or the Visual Basic Beep statement before you issue the ALERT() function or the MsgBox command. The following examples illustrate how to do this.

Visual Basic Example

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.



In Microsoft Excel version 5.0 or 7.0, open a new Visual Basic module and type the following code:

Sub Test()
   Beep                    'Causes the computer to beep
   MsgBox "Hello", 64      'Displays an information message box
End Sub
				




Microsoft Excel 4.0 Macro Example

In Microsoft Excel version 5.0 or 7.0, open a new Microsoft Excel 4.0 macro sheet and type the following macro:

   A1: =BEEP()
   A2: =ALERT("Hello")
   A3: =RETURN()
				


Explanation of Macro Code

A1: Causes the computer to beep.
A2: Displays an information alert box with the text: "Hello"
A3: Ends the macro.

Instead of using the =BEEP() function or the Beep procedure, you can use the SOUND.PLAY() function to play any sound before displaying the message box. For example, for a Visual Basic macro, use the following code:

   Application.ExecuteExcel4Macro "SOUND.PLAY(,""C:\WINDOWS\CHIMES.WAV"")"
				


For a Microsoft Excel version 4.0 macro, use the following code:

   =SOUND.PLAY(,"C:\WINDOWS\CHIMES.WAV")
				

Modification Type:MinorLast Reviewed:8/15/2005
Keywords:KB107137