ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I add sound alerts to Excel spreadsheets? (https://www.excelbanter.com/excel-programming/380058-re-how-do-i-add-sound-alerts-excel-spreadsheets.html)

Marvin

How do I add sound alerts to Excel spreadsheets?
 
Jim is there a way to accomplish the same in Excel 2003. The play commands
have been disabled.

"Jim Thomlinson" wrote:

Here is some code for playing a beep or a wave file...

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long

Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal
dwDuration _
As Long) As Long


Private Sub PlayMySound()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single

num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub
--
HTH...

Jim Thomlinson


"identijoe" wrote:

I want to alert users fo input errors using a barcode scanner to enter
container numbers into a spreadsheet. Entering non-matching numbers (two
different barcodes) need to envoke an "alert" sound.



All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com