I want to play one of two wav files

5 pts.
Tags:
Microsoft Excel
microsoft excel functions
I want to play one of two wav files when cell D11 value changed from Right to Wrong. What I have works perfectly for the value "Right". But I don't know how to change the code to play a wav for "Wrong". I tried adding a second modual but that did not work. Sheet 1 Private Sub Worksheet_Change(ByVal Target As Range) If Range("D11").Value = "Right" Then PlayWav End If End Sub Modual 1 Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Sub PlayWav() Dim WAVFile As String Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 On Error GoTo ErrHandler WAVFile = "C:UsersBillDesktopWhoopFlp.wav" Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) Exit Sub ErrHandler: End Sub
ASKED: June 20, 2012  5:03 AM
UPDATED: June 21, 2012  9:04 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try adding a PlayWav2() subroutine targeted to your desired .wav file and add a second if/then statement pointing to PlayWav2(). I would copy from Sub PlayWav() to End Sub, changing the WAVFile value and placing the new code beneath instead of adding a whole new module.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following