View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Marvin Marvin is offline
external usenet poster
 
Posts: 71
Default 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.