XL5: Continue Macro Execution While Playing a .WAV FileLast reviewed: September 2, 1997Article ID: Q107690 |
The information in this article applies to:
SUMMARYThe APPLICATION.SOUND.PLAY() or SOUNDNOTE.PLAY functions allow a macro to execute and play wave(.WAV) files. When you use these functions in a macro, Microsoft Excel must wait for the entire sound file to play before it can run the rest of the macro. You can use the following
MORE INFORMATIONWhen you play the .WAV file this way, the sound file continues to play while the macro finishes executing, and it appears as if Microsoft Excel is performing two tasks at once. To demonstrate this behavior, play a .WAV file describing the contents of a dialog box and then display the dialog box. The following sample macro can be used in Microsoft Excel, version 5.0, for this purpose. Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide." WARNING: The Declare Function statements listed in the following macro are very sensitive. If used incorrectly, these functions may cause a general protection (GP) fault in Windows or cause serious software problems.
'The following two lines should be entered as a single line on a 'modulesheet Declare Function sndPlaySound Lib "MMSYSTEM.DLL" (ByVal lpszSoundNameAs String,_ ByVal wFlags As Integer) As Integer
Sub main() 'Calls the sndPlaySound function and passes it the name of 'the sound file to play Call sndPlaySound("c:\bat\wave\close.wav", 0) End SubYou can replace c:\bat\wave\close.wav with the path to any valid .wav file. This macro assumes the that you are using Microsoft Windows 3.1 and have a compatible sound card installed. Software sound drivers such as SPEAK.EXE will not give the desired results (these drivers must play the entire sound file before allowing Microsoft Excel to continue execution of the macro). For more complete information about the sndPlaySound function of the MMSYSTEM.DLL, refer to the "Multimedia Programmer's Reference." This manual is part of the Microsoft Windows operating system version 3.1, Software Development Kit (SDK).
|
Additional reference words: 5.00 5.0 blaster soundblaster wss creative labs
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |