M
Marty
Hello, all:
I'm using Excel 2003. I've written a Jeopardy game, and just for a bit of
fun, I want to be able to play a MIDI of the final jeopardy theme. The MIDI
is called finaljeopardy.mid.
I got the following code from a book written by John Walkenbach
(www.j-walk.com). I figure I stand a better chance of getting a response
here than I do from him.
************************************************
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As
String) As Long
Sub PlayMIDI()
MIDIFile = "finaljeopardy.mid"
MIDIFile = ThisWorkbook.Path & "\" & MIDIFile
mciExecute ("play" & MIDIFile)
End Sub
Sub StopMIDI()
MIDIFile = "finaljeopardy.mid"
MIDIFile = ThisWorkbook.Path & "\" & MIDIFile
mciExecute ("stop" & MIDIFile)
End Sub
**********************************************************
I want to have a toggle button which will alternately start and stop the
MIDI, but I can't get it to work. I tried using individual buttons (created
from textboxes) and assigning the StartMIDI and StopMIDI procedures to them
as macros, but I get a "The driver cannot recognize the specified command"
error message box (from Excel, not from VBA).
Qhestions I have:
1. I have the code stored in Module1 of the workbook. Is this the correct
location, or should it be stored on the sheet where I have the buttons?
2. Where do I need to put the MIDI file in order for the code to access it?
3. How can I use a toggle button instead of two individual buttons?
You can probably tell that this is over my head, but I'm hoping some of you
can help me out by showing me how the code should be set up and answering my
questions.
Thanks in advance,
MARTY
I'm using Excel 2003. I've written a Jeopardy game, and just for a bit of
fun, I want to be able to play a MIDI of the final jeopardy theme. The MIDI
is called finaljeopardy.mid.
I got the following code from a book written by John Walkenbach
(www.j-walk.com). I figure I stand a better chance of getting a response
here than I do from him.
************************************************
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As
String) As Long
Sub PlayMIDI()
MIDIFile = "finaljeopardy.mid"
MIDIFile = ThisWorkbook.Path & "\" & MIDIFile
mciExecute ("play" & MIDIFile)
End Sub
Sub StopMIDI()
MIDIFile = "finaljeopardy.mid"
MIDIFile = ThisWorkbook.Path & "\" & MIDIFile
mciExecute ("stop" & MIDIFile)
End Sub
**********************************************************
I want to have a toggle button which will alternately start and stop the
MIDI, but I can't get it to work. I tried using individual buttons (created
from textboxes) and assigning the StartMIDI and StopMIDI procedures to them
as macros, but I get a "The driver cannot recognize the specified command"
error message box (from Excel, not from VBA).
Qhestions I have:
1. I have the code stored in Module1 of the workbook. Is this the correct
location, or should it be stored on the sheet where I have the buttons?
2. Where do I need to put the MIDI file in order for the code to access it?
3. How can I use a toggle button instead of two individual buttons?
You can probably tell that this is over my head, but I'm hoping some of you
can help me out by showing me how the code should be set up and answering my
questions.
Thanks in advance,
MARTY