Consulting

Results 1 to 19 of 19

Thread: System beep

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,090
    Location

    System beep

    After my code is done I want it to run a system beep. How can I do this?

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    2,698
    Location
    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.

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,090
    Location
    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

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    2,698
    Location
    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.

  5. #5
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,090
    Location
    lol I have the sound up all the way right now. lol

  6. #6
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,090
    Location
    I just tried this code on another computer and it didn't work either? have any idea why?

  7. #7
    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!".

  8. #8
    I just thought of something. Maybe you can get the speech facility to help you. Look into it ... it's really kinda cool.

  9. #9
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,090
    Location
    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.

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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

  11. #11
    Or you can put the following statement at the end of your code:
    [VBA]Application.Speech.Speak("Beep")[/VBA]

  12. #12
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,487
    Location
    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'

  13. #13
    VBAX Guru
    Joined
    Mar 2005
    Posts
    2,698
    Location
    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?

  14. #14
    What reference should I have that I might not have??

    P.S. I can use the text to speech feature OK.

  15. #15
    VBAX Guru
    Joined
    Mar 2005
    Posts
    2,698
    Location
    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

  16. #16
    VBAX Newbie
    Joined
    Jun 2006
    Location
    Oregon
    Posts
    3
    Location
    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.

  17. #17
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by OBP
    Daniel, it works for me, although it is very difficult to get it to beep more than once.
    [VBA]Sub test()
    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.

  18. #18
    VBAX Contributor compariniaa's Avatar
    Joined
    Jun 2006
    Location
    Santa Clarita, CA
    Posts
    117
    Location
    Quote Originally Posted by Djblois
    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
    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:

    [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.

  19. #19
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •