Play and stop sound

0

0-0 Wai Wai ^-^

I'm new to VBA.
1) Play sound as long as the criteria are satisifed
The sound is played and looped as long as the criteria are satisfied
However a user can stop this sound manually if desired.

2) Play sound as long as the message box is not dismissed
A message box will pop up when the criteria are satisifed.
The sound is played and looped at the same time.
The sound will stop after the user has acknowledged the message by clicking on
"ok" of the message box.

3) Stop sound
How to create a code which can stop specific sounds, but not every sound which
is playing?

Thank you.

PS:
Here's the code (incomplete) for Q1-2:

Function Alarm(Cell, Condition1, Condition2, ..., Message_text) 'incomplete
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Const SND_LOOP = &H8
On Error GoTo ProcessErr
If Evaluate(Cell.Value & Condition) Then
WAVFile = "C:\WINDOWS\Media\alert.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP)
MsgBox " {Message_text}" 'incomplete
Alarm = True
Exit Function
End If

ProcessErr:
Alarm = False
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top