After my code is done I want it to run a system beep. How can I do this?
After my code is done I want it to run a system beep. How can I do this?
The VBA comand for making the beep sound is
Beep
It will sound just one beep so if you want more you need to repeat the line of code or put it in a loop.
I put beep in but it doesn't make a sound? And I don't have it on mute and I can hear other sounds.
Daniel
Daniel, it works for me, although it is very difficult to get it to beep more than once.
You may need to turn the sound up higher to hear it.
lol I have the sound up all the way right now. lol
I just tried this code on another computer and it didn't work either? have any idea why?
I tried to get Beep to work on 3 different computers, and I never heard anything. What I really need is a sound that goes "phffft!".
I just thought of something. Maybe you can get the speech facility to help you. Look into it ... it's really kinda cool.
Since, the system beep won't work can someone help me to get it to make any sound? I just want it to make a noise when it is done.
How about using a .wav file?
[VBA]
Option Explicit
'API Class to take care of playing the file
Public Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Sub VBASound()
'Call Api to play LoadIt.wav witch is in the same folder as
'the active document!
Call sndPlaySound32(ActiveWorkbook.Path & "\LoadIt.WAV", 0)
End Sub
[/VBA]
I think this is a kb entry from some time ago.
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Or you can put the following statement at the end of your code:
[VBA]Application.Speech.Speak("Beep")[/VBA]
For sound see here
http://www.vbaexpress.com/forum/showthread.php?t=8736
Hi Steve,
DRJ did the Sound KB
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
I have just had a thought, the guys that can't get the sound to work, what References have you got ticked in the reference library?
What reference should I have that I might not have??
P.S. I can use the text to speech feature OK.
I have the following ticked
Visual Basic For Applications - (Which I assume you must have)
Microsoft Excel 10.0 Object Library
OLE Automation
Microsoft Office 10.0 Object Library
Also for Beep, you need to make sure that you have a sound assigned for Default Beep in the Sounds & Multimedia (this is what it's called in Windows 2000, not sure about XP) Control Panel.
[VBA]Sub test()Originally Posted by OBP
Beep
Application.Wait Now + TimeValue("00:00:01")
Beep
End Sub[/VBA]
And the sound works for me...
Windows XP
Excel 2003
New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.
I think system admins can turn sounds off for computers, which may affect whether or not you can hear the beep. I can hear sounds on my PC, evidenced by this macro:Originally Posted by Djblois
[vba] sub Sound()
If Application.CanPlaySounds = False Then
MsgBox "Your computer cannot play sounds"
Else
MsgBox "Your computer can play sounds"
End If[/vba] hope this helps
Last edited by compariniaa; 07-17-2006 at 03:33 PM.
Yes, that is not to be forgotten. I recently was trying to use an API to play a WAV sound, and it kept failing. I added:
Application.EnableSound = True
and ...Voila!.. it worked!