![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks guys...
Tom |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 81
|
Using VB MIcrosofr has a MCI control (Media control interface)
this control connects to most spound sources.... guess you could use its properties to play a sound?? Ed |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Hi Tom
You can Play virtually anything you like and in a number of ways. What excatly do you want to do ?? If you like I can send you example files to Play a Wave,Midi,MP3,AVI files located either on your drive or embeded in an excel File..... |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks for the replies...
I created a spreadsheet for my daughter to practice her multiplication. It is set up like a game with command buttons and a timer. I'd like to add sounds for various events. Wrong Answer Right Answer High Score Timer Clicks Ect... I could find nothing in help... Thanks again! Tom P.S. Thanks Ivan for the offer... I'd love to have the example files... If you have any kids, I'll send you the spreadsheet when I'm done... Tom [ This Message was edited by: TsTom on 2002-05-01 01:41 ] |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Hi Tom
Just to get you started. Why not record what you want eg...WRONG ANSWER, RIGHT ON etc....probably sound better coming from Mum Then just use this code to play the wave files you have recorded. Option Explicit Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Public Const SND_SYNC = &H0 Public Const SND_ASYNC = &H1 Public Const SND_NODEFAULT = &H2 Public Const SND_MEMORY = &H4 Public Const SND_LOOP = &H8 Public Const SND_NOSTOP = &H10 Dim SndFile As String Dim wFlags As Double Dim PlayIt Sub WAVPlay(File) Dim SoundName As String SoundName = File wFlags = SND_ASYNC Or SND_NODEFAULT PlayIt = sndPlaySound(SoundName, wFlags) End Sub Sub Wrong() SndFile = "C:MEDIAwrong.wav" If Dir(SndFile) = "" Then MsgBox "Sorry no File to Play!": End PlayIt = sndPlaySound(SndFile, SND_ASYNC) End Sub Tom....I have Kids would appreciate a copy |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
What you have right there is great, Ivan...
Would like to know how to play midi files as well. Thanks! |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Option Explicit Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" _ (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, _ ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long '// Function Discription: '// The mciSendString function sends a command string to an MCI device. '// The device that the command is sent to is specified in the command string. '// '// Success: '// Returns zero if successful or an error. '// The low-order word of the returned doubleword value contains the error return value. '// If the error is device-specific, the high-order word of the return value is the '// driver identifier; otherwise, the high-order word is zero. '// '// Parametre discriptions: '// -lpszCommand '// Address of a null-terminated string that specifies an MCI command string. '// For more information about the command strings, see Command Strings. '// '// -lpszReturnString '// Address of a buffer that receives return information. '// If no return information is needed, this parameter can be NULL. '// '// -cchReturn '// Size, in characters, of the return buffer specified by the lpszReturnString parameter. '// '// -hwndCallback '// Handle of a callback window if the "notify" flag was specified in the command string. Const sMidiFile As String = "C:WINDOWSMEDIAimposs[1].mid " Dim Play Sub Play_Midi() '// Discription: '// Plays a Midi sound File '// Specified by Const sMidiFile '// Play = mciSendString("play " & sMidiFile, 0&, 0, 0) If Play <> 0 Then MsgBox "Can't PLAY!" End Sub Sub Stop_Midi() Play = mciSendString("close " & sMidiFile, 0&, 0, 0) End Sub |
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks alot guys and Ivan especially, as usual.
Tom |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
Hi Tom --
I would like a copy too if that is okay when youre done. My kid will do these things as long as they are "cool." thanks!! |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Apr 2002
Posts: 134
|
I would like a copy when its done, Thanks
Dsuperc@hotmail.com |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|