ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I pre-load wav file into memory on opening excel wb? (https://www.excelbanter.com/excel-programming/434117-can-i-pre-load-wav-file-into-memory-opening-excel-wb.html)

MikeZz

Can I pre-load wav file into memory on opening excel wb?
 
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!


Chip Pearson

Can I pre-load wav file into memory on opening excel wb?
 

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!


MikeZz

Can I pre-load wav file into memory on opening excel wb?
 
Hi Chip,
At first I was having difficulties but figured it out.
Your solution works perfectly as usual!

The only problem I have now is that the "KeepTime" and "AlarmSound"
functions I've found on the internet cause the mouse to blink to an hourglass
for just a fraction of a second. It doesn't seem to interupt the mouse
enough to mess with the functionality... but it's darn right agitating to see
it blink for that fraction of a second.

Any ideas on fixing that problem would be just fantastic!

Thanks again for the great assistance!

MikeZz


"Chip Pearson" wrote:


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!




All times are GMT +1. The time now is 02:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com