I use Excel to pull live data from a financial exchange and want to create some audio alerts.

The data comes in every 500ms and therefore the worksheet change event fires every 0.5 seconds.

Some of the audio files I am using are longer than 0.5 seconds and the problem i've got is that they are looping before they have finished.
Also, the audio files that are less than 0.5 secs long to not need to be played so frequently and i would rather be able to set the period of time between plays.

If i switch the Uflag to &H8 the code pauses and therefore i don't get a reliable feed of data from the exchange

''' taken from cpearson
Const SND_SYNC = &H0 ' (Default) Play the sound synchronously. Code execution
' pauses until sound is complete.
Const SND_ASYNC = &H1 ' Play the sound asynchronously. Code execution
' does not wait for sound to complete.
Const SND_LOOP = &H8 ' Continue playing sound in a loop until the next
' call to sndPlaySound. """


Private Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub worksheet_change(ByVal Target As Range)

If Range("A2").Value > Range("A3").Value Then sndPlaySound32 "C:\Users\Bob\Desktop\Audio\warning.wav", &H1

end sub


What i need is to either be able to play the sound file till the end without pausing the code
or
When the conditions are met play the file and then wait x seconds before checking the condition again and playing/not playing the audio file.


Thanks in advance

Thanks in advance