Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel Sound Alert (2002/2003)

    I would like to play a sound alert (standard wav file) when a particular condition is met in a spreadsheet cell. Specifically, I have live stock quotes coming into a spreadsheet through DDE and would like to play a sound alert when a particular value or condition is met. That trigger value or condition would be placed in another cell. I have programmed a few Excel macros, though am no expert on macros by any means, but I cannot find any command to play a sound. Could somebody please explain how I could do this?

    Thanks and regards,
    Rob

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

    Re: Excel Sound Alert (2002/2003)

    If you want to sound the system beep, you can simply use
    <code>
    Beep
    </code>
    To play a .wav file, place the following declarations at the top of a module:
    <code>
    Private Const SND_ASYNC = &H1 ' play asynchronously
    Private Const SND_FILENAME = &H20000 ' name is a file name

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    </code>
    You can then use an instruction such as the following to play a sound in your code:
    <code>
    PlaySound "C:WindowsMediaTada.wav", 0, SND_FILENAME Or SND_ASYNC</code>

  3. #3
    New Lounger
    Join Date
    Jun 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel Sound Alert (2002/2003)

    Thanks very much Hans. I will give this a try tomorrow.

    Regards
    Rob

Posting Permissions

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