Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Sound on Re-Calc (Excel 2000)

    Hi,

    I found this bit of code on John Walkenbach's web page and am trying to implement it in a workbook without success. the formula calculates to True/False, but I can't hook it up to a sound file. The <font color=blue>blue</font color=blue> text is the line of code I can't get to work!
    Could anyone give me any assistance!

    <pre>'Windows API function declaration
    Private Declare Function PlaySound Lib "winmm.dll" _
    Alias "PlaySoundA" (ByVal lpszName As String, _
    ByVal hModule As Long, ByVal dwFlags As Long) As Long


    Function Alarm(Cell, Condition)
    Dim WAVFile As String
    Const SND_ASYNC = &H1
    Const SND_FILENAME = &H20000
    On Error GoTo ErrHandler
    If Evaluate(Cell.Value & Condition) Then
    WAVFile = ThisWorkbook.Path & "sound.wav" 'Edit this statement
    <font color=blue>'WAVFile = "C:Program FilesMicrosoft OfficeOffice10Media" & _
    "sound1.wav" 'Edit this statement</font color=blue>
    Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
    Alarm = True
    Exit Function
    End If
    ErrHandler:
    Alarm = False
    End Function
    </pre>


    The Alarm function monitors a cell for a specified condition. If the condition is met, the sound file is played and the function returns TRUE. If the condition is not met, the sound file is not played and the function returns FALSE.

    Following are examples of formulas that use this function:
    =Alarm(A1,">=1000")
    The sound will play when the value in cell A1 is greater than or equal to 1000.
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sound on Re-Calc (Excel 2000)

    Office10 is the folder in which Office XP is installed by default. Since you mention Excel 2000 in the subject, I assume that you don't have an Office10 folder. It is probably called just Office on your PC. Search your hard disk for .wav files, then replace the path+filename in the statement by one that is valid on your PC.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Sound on Re-Calc (Excel 2000)

    I created that exact path on my computer and put a sound file in it and it gavbe me no problem
    What do you mean "can't get to work": can you be more specific?

    Steve

  4. #4
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sound on Re-Calc (Excel 2000)

    <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15>
    Thanx...I meant Excel XP in the subject line....
    It's working now....I simply discovered that <span style="background-color: #FFFF00; color: #FFFF00; font-weight: bold">my volume button was turned down!!!!!!!</span hide> <img src=/S/blush.gif border=0 alt=blush width=15 height=15> <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>
    Regards,
    Rudi

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sound on Re-Calc (Excel 2000)

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Sound on Re-Calc (Excel 2000)

    Don't feel bad. When I installed XP SP2 on my home machine, for no known reason it turned all the volume settings down to zero in Control Panel, Sounds settings. Of course I had no idea that SP2 would do that, and spent two hours trying to diagnose what was wrong with MusicMatch JukeBox!
    -John ... I float in liquid gardens
    UTC -7ąDS

  7. #7
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sound on Re-Calc (Excel 2000)

    Thanx, makes me feel better. I felt like a mouse when I replied that the volume was down.!
    Regards,
    Rudi

Posting Permissions

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