|
|
|
|
|
|
Excel
|
Play Different Beeps
|
|
Ease of Use
|
Easy
|
Version tested with
|
2000, 2002
|
Submitted by:
|
Justinlabenne
|
Description:
|
Function that can easily the type of windows Beep style
|
Discussion:
|
Can be used to easily switch between the type of windows beeps that are available. If your code utilizes an error handler, you can use a windows beep in your code that sounds when an error occurs, or another type when your code completes successfully as another helpful way to distinguish what is happening / happened when your code ends.
|
Code:
|
instructions for use
|
Option Explicit
Private Declare Function MessageBeep& Lib "user32" (ByVal wType As Long)
Public Enum BeepTypes
MB_OK = &H0&
MB_ICONASTERISK = &H40&
MB_ICONEXCLAMATION = &H30&
MB_ICONHAND = &H10&
End Enum
Public Function BeepType(lSound As BeepTypes) As Long
BeepType = MessageBeep(lSound)
End Function
Sub TestTheBeep()
BeepType MB_ICONHAND
End Sub
|
How to use:
|
- Open an Excel Workbook
- Copy the code
- Press Alt + F11 to open the Visual Basic Editor (VBE)
- Select INSERT > MODULE from the menubar
- Paste code into the right pane
- Press Alt+Q to return to Excel
- Save workbook before any other changes
|
Test the code:
|
- Go to TOOLS > MACRO > MACROS
- When the dialog appears, select (TestTheBeep)
- Press Run
|
Sample File:
|
Beep.zip 7.62KB
|
Approved by mdmackillop
|
This entry has been viewed 262 times.
|
|