Beep

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know how to play a .wav file.

I know that the Beep function does not allow to play different sounds.

Is there an easy way to emit two or three (or several) different sounds
without resorting to playing a wav file?
 
You can change the frequency of the beep if you impliment the API...
Something like this in a standard code module...

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

Sub TestBeep()
Beep 500, 100
Application.Wait (Now + TimeSerial(0, 0, 1))
Beep 1000, 100
Application.Wait (Now + TimeSerial(0, 0, 1))
Beep 5000, 100
Application.Wait (Now + TimeSerial(0, 0, 1))
Beep 2000, 100
Application.Wait (Now + TimeSerial(0, 0, 1))
Beep 200, 100
End Sub
 
Sorry I should have mentioned that you can also change the duration of the
sound...

Sub TestBeep2()
Beep 500, 100
Beep 1000, 200
Beep 5000, 100
Beep 2000, 300
Beep 200, 700
Beep 500, 200
Beep 1000, 400
Beep 5000, 700
Beep 2000, 200
Beep 200, 100
End Sub
 
oh, i see the function is needed.

--


Gary


Jim Thomlinson said:
Sorry I should have mentioned that you can also change the duration of the
sound...

Sub TestBeep2()
Beep 500, 100
Beep 1000, 200
Beep 5000, 100
Beep 2000, 300
Beep 200, 700
Beep 500, 200
Beep 1000, 400
Beep 5000, 700
Beep 2000, 200
Beep 200, 100
End Sub
 
You can change the beep sound by going to Start>Control Panel>Sounds, Speech
& Audio devices>Sounds & Audio Devices>Sounds tab>Click on Default Beep, then
click Browse. The only selections offered are .wav sounds but you can change
the Beep sound.
 
Just to avoid confusion with the standard VBA Beep statement, I would modify
the code as follows:

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

Sub TestBeep()
API_Beep 500, 100
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top