XL: Alert Function May Not Beep

Last reviewed: September 13, 1996
Article ID: Q107137

The information in this article applies to:

  • Microsoft Excel for Windows, version 5.0
  • Microsoft Excel for Windows 95, version 7.0

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 engineers 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")


KBCategory: kbusage kbtlc
KBSubcategory: xlwin

Additional reference words: 5.00 7.00 dialog



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 13, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.