Option Compare Database
Option Explicit

Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long

Public Function PlayMidi()
Dim strMidiFile As String, lngRet As Long, x As Long
Dim strOpenCommandString As String
Dim strErrorString As String

strErrorString = Space(255)
strMidiFile = InputBox("Enter the name of the .MID file:", "Play MIDI File", _
  "C:\Windows\Media\Passport.Mid")
If Trim(strMidiFile) = "" Then Exit Function
strOpenCommandString = "open " & Trim(strMidiFile) & " type sequencer alias midfile"

lngRet = mciExecute(strOpenCommandString)
lngRet = mciExecute("play midfile wait")
lngRet = mciExecute("close midfile")

End Function

