Re: Using Countdown in Status Bar to Play Sound

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bob Phillips (bob.phillips_at_notheretiscali.co.uk)
Date: 02/06/04


Date: Fri, 6 Feb 2004 15:09:59 -0000

Monty,

Here's some code to play a WAV file

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
   (ByVal lpszName As String, _
    ByVal hModule As Long, _
    ByVal dwFlags As Long) As Long

Sub PlayWAVFile(Optional Async As Boolean = True)
Dim WavFile As String
    WavFile = "chimes.wav"
    WavFile = "C:\Windows\Media\" & WavFile
    If Async Then
        Call PlaySound(WavFile, 0&, SND_ASYNC Or SND_FILENAME)
    Else
        Call PlaySound(WavFile, 0&, SND_SYNC Or SND_FILENAME)
    End If
End Sub

If you need to know how to insert it in your code, we will need to see that

-- 
HTH
Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Full Monty >" <<Full.Monty.117m8e@excelforum-nospam.com> wrote in message
news:Full.Monty.117m8e@excelforum-nospam.com...
> Running Excel 97:
>
> Currently using a Countdown (shown in the Excel tips) from 180 to 0 in
> th status bar as a timer.
>
> Would like Excel to automatically play a corresponding WAV file once
> the countdown reaches certain intervals. (30, 10, 0)
>
> Each of the three intervals listed would have their own WAV file.
>
> I am just learning VBA and this site has been very helpful thus far.
> But I am stuck at this point and don't know how to proceed.
>
> Thanks for the help!
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


Relevant Pages

  • Re: play a wav
    ... Const SND_FILENAME = &H20000 ... But It doesn't play the wav file. ... DirectX, whatever that means, does not imply you have to use DirectSound. ...
    (microsoft.public.win32.programmer.directx.audio)
  • getting a WAV file to loop in vb 6 ?
    ... I am using the module below to play a WAV file. ... Public Sub sub_Play_Wav(ByVal s_File As String) ...
    (comp.programming)
  • Re: add WAV file
    ... Const SND_ASYNC = &H1 'continue executing code even if sound isn't ... Public Function PlayASound(SoundFile As String) As Boolean ... 'Flags indicate that sound is a file, to play asynchrounously, ...
    (comp.lang.basic.visual.misc)
  • Re: Add Sound to command button event
    ... Play A Sound In Any Event ... To play a sound in any event, just set an event such as a form's OnOpen to: =PlaySoundPaste the following declaration and function into a module and save: Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _ (ByVal filename As String, ByVal snd_async As Long) As Long Function PlaySound ... > Need to have a sound bite play on click of a command button, a *.wav file or> similar. ...
    (microsoft.public.access.formscoding)
  • Re: attach a .wav file
    ... To play a sound in any event, just set an event such as a form's OnOpen to: ... Function PlaySound(sWavFile As String) ... > Can I somehow attach a .wav file to an event. ...
    (microsoft.public.access.formscoding)