LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default HOW TO PLAY SOUND.WAV FILES SIMULTANEOUSLY UNDER EXCEL

I have a requirement to trigger 3 sound effects during execution of an Excel
macro. When the Workbook opens, Function Keys are assigned to each Sound
procedure as follows:

Option Explicit
Private Sub Workbook_Open()

' ASSIGN FUNCTION KEYS

Application.OnKey "{F1}", "Sound1"
Application.OnKey "{F2}", "Sound2"
Application.OnKey "{F3}", "Sound3"

End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)

' RESET FUNCTION KEYS

Application.OnKey "{F1}"
Application.OnKey "{F2}"
Application.OnKey "{F3}"

End Sub

The following Windows API function declarations appear in the Module code:

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000

The individual Sound procedures a

Public Sub Sound1()

Call PlaySound(ThisWorkbook.Path & "\sound1.wav", 0&, SND_ASYNC Or
SND_FILENAME)

End Sub
Private Sub Sound2()

Call PlaySound(ThisWorkbook.Path & "\sound2.wav", 0&, SND_ASYNC Or
SND_FILENAME)

End Sub
Private Sub Sound3()

Call PlaySound(ThisWorkbook.Path & "\sound3.wav", 0&, SND_ASYNC Or
SND_FILENAME)

End Sub

When F1 is pressed, sound1.wav file plays, and similarly when F2 and F3 are
pressed, the corresponding sound2.wav and sound3.wav files play. So far, so
good. If a second sound file is triggered before the first one has finished
playing, the first one is abandoned, and the second plays alone. What I want
is to allow more than one sound file to be triggered and play to completion
without being interrupted.

Is there way of achieving this, perhaps involving a different Windows API
function declaration? Or would 3 Sound Cards be needed to play the wav files
completely independently?
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
play sound when closing xcel 2007 Pirgnori Excel Discussion (Misc queries) 1 December 28th 09 09:21 PM
Play sound aac Excel Discussion (Misc queries) 2 December 5th 07 11:24 PM
Play Sound File Once when cell value condition id met John 1 Excel Discussion (Misc queries) 4 September 1st 07 04:32 PM
play sound when pressing commandbutton Hoyos Excel Discussion (Misc queries) 1 August 19th 07 04:12 PM
Using Countdown in Status Bar to Play Sound Full Monty Excel Programming 5 February 6th 04 05:37 PM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"