You can't preload the sound file. However, a sound can be played
synchronously or asynchronously. In synchronous sound, the code will
pause execution until the sound has complete playing, In asychronous
sound, the wav is sent to the function but code continues to execute
while the sound is playing. E.g,
Public Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Const PLAY_SOUND_SYNC As Long = 0& ' wait for completion
Const PLAY_SOUND_ASYNC As Long = 1& ' do not wait
Sub AAA()
sndPlaySound32 "C:\Windows\Media\chimes.wav", ASYNC
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Thu, 24 Sep 2009 21:58:01 -0700, MikeZz
wrote:
Hi,
I have a workbook that I want to have play certain wav files as alerts.
These are not the windows standard wav files so whenever an even triggers a
wav aleart, excel has to open the file and then play it.
This slows things down as the mouse icon turns into the "hour-glass" for a
second.
Is there a way to have excel either run the playsound in the background or
preload the file into memory so there is no wait?
Thanks!