View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jef Gorbach Jef Gorbach is offline
external usenet poster
 
Posts: 59
Default Simple Sound Macro


from:
http://www.exceltip.com/st/Playing_W...osoft_Excel/46
0.html
It's easy to play soundfiles in WAV-format. You only need to know the
filename of the sound you want to play, and decide if you want the macro to
wait while the sound plays or not.

Here is an example:
Public Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub PlayWavFile(WavFileName As String, Wait As Boolean)
If Dir(WavFileName) = "" Then Exit Sub ' no file to play
If Wait Then ' play sound before running any more code
sndPlaySound WavFileName, 0
Else ' play sound while code is running
sndPlaySound WavFileName, 1
End If
End Sub

Sub TestPlayWavFile()
PlayWavFile "c:\foldername\soundfilename.wav", False
MsgBox "This is visible while the sound is playing..."
PlayWavFile "c:\foldername\soundfilename.wav", True
MsgBox "This is visible after the sound is finished playing..."
End Sub




"chalky" wrote in
message ...

Thanks for this. The sound i had planned would actually be stored on
the hard drive, i need the programming to actually play this sound file
as the Macro runs


--
chalky
------------------------------------------------------------------------
chalky's Profile:

http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=501011