Fișierele sonore în format MIDI sunt adesea lungi, deci ar putea fi necesar să opriți redarea
sunetul (de ex., când macro-ul este terminat). Iată un exemplu:
Private Declare Function mciExecute Lib "winmm.dll" _ (ByVal lpstrCommand As String) As Long Sub PlayMidiFile (MidiFileName As String, Play As Boolean) If Dir (MidiFileName) = "" Then Exit Sub 'no file to play If Play Then mciExecute "play" & MidiFileName 'începe jocul Altfel mciExecute "stop" & MidiFileName' oprește redarea End If End Sub Sub TestPlayMidiFile () PlayMidiFile "c: \ foldername \ soundfilename.mid", True MsgBox "Faceți clic pe OK când fișierul MIDI începe redarea … "MsgBox" Faceți clic pe OK pentru a opri redarea fișierului MIDI … "PlayMidiFile" c: \ foldername \ soundfilename.mid ", False End Sub