Play Multiple Sounds

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
163
Hello,
I'm currently using the below code to which plays a .wav file on command:

Code:
Option Explicit
 
Private Declare Function PlaySound Lib "winmm.dll" _
  Alias "PlaySoundA" (ByVal lpszName As String, _
  ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
 
Sub PlayWAV()
    Dim WAVFile As String
    WAVFile = "FOXNFL.wav"
    WAVFile = "S:\FMS\FMS\Templates\Sheets\Playbook\FOXNFL.wav"
    Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
 
End Sub

Can some one please tell me how I can add/amend this code to play another (seperate) .wav file? I tried to add another module and changed the Sub to "PlayWAV2" with no luck.

Thanks.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try in the same module like this

Code:
Private Declare Function PlaySound Lib "winmm.dll" _
  Alias "PlaySoundA" (ByVal lpszName As String, _
  ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
 
Sub PlayWAV()
    Dim WAVFile As String
    WAVFile = "S:\FMS\FMS\Templates\Sheets\Playbook\FOXNFL.wav"
    Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
 
End Sub

Sub PlayWAV2()
    Dim WAVFile As String
    WAVFile = "S:\FMS\FMS\Templates\Sheets\Playbook\XXX.wav"
    Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
 
End Sub
 
Upvote 0
Dear all,

Play sound Wav in Excel, after saved can't play?

I have done as like above programming, and can run properly, but after saved, the sounds are heard only "ding".

I creating timer/scheduler using Excel, with as logical something like this:

=IF(logic1,play1.wav,IF(logic2,play2.wav,play3.wav))

as like this:
Excel Developer Tip: Playing a Sound Based on a Cell's Value

Reference:
Yahoo! Answers - Play sound Wav in Excel?

And done already, but after saved, the formula can't play the wav as in VBA, just "ding" sound appear.

Might somebody help me please.
Thank you.
 
Upvote 0

Forum statistics

Threads
1,203,099
Messages
6,053,526
Members
444,669
Latest member
Renarian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top