XL: How to Play Sounds Using Visual Basic for ApplicationsID: Q158140
|
In Microsoft Excel 97, cell notes have been replaced with cell comments and no longer support sound notes. However, you can use a Visual Basic for Applications procedure to play sounds. In order to play a sound in a Visual Basic for Applications procedure, a Windows API function, sndPlaySound32(), can be used to play a wave (.wav) file.
Microsoft provides programming examples 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 article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspTo use the macro, enter the following declaration and Sub procedure into a Module sheet. Run the PlaySound macro to hear the chimes wave file.
'This function declaration must be entered onto a single line.
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Sub PlaySound()
If Application.CanPlaySounds Then
'Substitute the path and filename of the sound you want to play
Call sndPlaySound32("c:\win95\media\chimes.wav", 0)
End If
End Sub
You can replace C:\Win95\Media\Chimes.wav with any valid wave file.
Q156200 XL97: Sounds Not Converted with Cell Notes
Q149777 XL: How to Play a Warning Sound If Critical Value Is Exceeded
Additional query words: XL97 xl7 8.00 api
Keywords : kbprg kbdta kbdtacode KbVBA
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type :
Last Reviewed: July 14, 1999