VBA Play audiofile without stopping code

hannah2233

New Member
Joined
May 7, 2014
Messages
15
Hey guys!!

In VBA i made a countdown timer, when it gets to 0 it executes an .wav audiofile then the countdown timer resets and counts down again. The problem is the code waits for the audiofile to play (~3 sec) before continuing. So you could imagine, if I counted down for 1min, the actual time would be 1min, 3seconds.

Is there a way to get the audiofile to play, while the remaining code still runs? I tried SND_ASYNC but that hasnt seemed to work. This is what code I have


Code:
Declare PtrSafe Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpazSoundName As String, ByVal uFlags As Long) As Long

Public Const MySoundsPath = "C:\Users\Hannah\Music\"


Sub Playbeep()
    sndPlaySound32 MySoundsPath & "wololo.wav ", SND_ASYNC
End Sub

Much love, hannah
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top