ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I want to *beep* *beep*!!!! (https://www.excelbanter.com/excel-programming/292023-re-i-want-%2Abeep%2A-%2Abeep%2A.html)

Jake Marx[_3_]

I want to *beep* *beep*!!!!
 
Hi Rob,

Application.Wait won't give you the precision you need to space out your
beeps. You could use the Sleep API function:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub MultiBeep(NumBeeps As Integer)
Dim Counter As Integer

For Counter = 1 To NumBeeps
Interaction.Beep
Sleep 200
Next Counter
End Sub


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Rob wrote:
This only beeps once. I think I need to add in a line like
application.wait or something, but that didn't work, so does anyone
know what I should do? Thanks. Have a good Weekend.
Rob

Sub MultiBeep(NumBeeps)
Dim Counter
For Counter = 1 To NumBeeps
Beep
Next
End Sub



david mcritchie

I want to *beep* *beep*!!!!
 
You might consider using a .wav file instead.

'Related material on sound can be found at John Walkenbach's
' Tip 59 Playing Sound From Excel
' http://www.j-walk.com/ss/excel/tips/tip59.htm

Option Explicit
' Declare Function sndPlaySound32 Lib "c:\winnt\system32\winmm.dll" _'
Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
'can be called from a worksheet subroutine

Sub Double_beep()
Call sndPlaySound32("c:\i386\ringout.wav", 0)
End Sub

' Example of an Event Macro -- you will need to make playvalue100 in
' a regular module
' Option Explicit
' Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' If Target.Address(0, 0) = "A1" And Target.Value = 100 Then
' playvalue100
' End If
' End Sub


For something interesting like playing every .wav file on your system
see http://www.mvps.org/dmcritchie/excel/code/beeps.txt
http://www.mvps.org/dmcritchie/excel/funstuff.htm



--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Jake Marx" wrote in message ...
Hi Rob,

Application.Wait won't give you the precision you need to space out your
beeps. You could use the Sleep API function:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub MultiBeep(NumBeeps As Integer)
Dim Counter As Integer

For Counter = 1 To NumBeeps
Interaction.Beep
Sleep 200
Next Counter
End Sub


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Rob wrote:
This only beeps once. I think I need to add in a line like
application.wait or something, but that didn't work, so does anyone
know what I should do? Thanks. Have a good Weekend.
Rob

Sub MultiBeep(NumBeeps)
Dim Counter
For Counter = 1 To NumBeeps
Beep
Next
End Sub






All times are GMT +1. The time now is 08:10 PM.

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