Consulting

Results 1 to 9 of 9

Thread: Beep in Excel

  1. #1

    Beep in Excel

    Hi,

    I am trying to create a macro whereby there is a beep whenever a certain function is hit/run, i.e. when a variable is hit then a beep of some sort sounds.

    Any ideas on how this may be achieved?

    Thanks

    Sarah


  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    It's actually for a friend of mine who is a primary teacher - she is teaching the kid's how to use excel, i.e. how to open and do basic math (eg 5x4) on it and was asking me if there was a way that it could be used to try and make using math and excel a bit more fun.... attantion span of kid's is not the longest!!!!

  4. #4
    Hi,

    I have found a bit of code in Google that will work for me... might keep the school kids interested for a little while!!

    thanks for your help

    Sarah

  5. #5
    Hi,

    I have attached the code if anyone is interested in the above function - it sends out several different types of beeps.


    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

  6. #6
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Sarah,

    Thanks for sharing your findings.

    Did you try using Beep by itself? I see it and some examples mentioned in Help.

    And for the Lurkers, Sarah's code works for Windows but not Mac.

    Cheers!
    Ron
    Windermere, FL

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    A bit more complex, but gives the possibility of different beeps in this thread
    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'

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If you want to play a .wav file you might try this. Save your excel file and put the wave file in the same directory. Change the name of the wave file in the code to match what you want to play. Name in the code is LoadIt.WAV:

    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
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    Anyone who can set my beep up to play Chopsticks I'll help them finish a keg of Guinnes next time they're in Dublin :-)

    Thanks for all the help

    Sarah

Posting Permissions

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