Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to play .wav in Excel

Status
Not open for further replies.

ramnewbietoaccess

Programmer
Nov 4, 2002
52
US
Hello

I have a folder which contains an excel application and .wav files. I have user forms where end users can view a product. I would LOVE to somehow make it so that they can 0n event hear a small .wav file to hear about the product. Anyone have an idea?

Thanks in advance!
 
didn't do a lot of research on this did you ??

Just entered "Play wav file in excel" and the 1st hit brought up this:

Code:
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

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top