Thật dễ dàng để phát tập tin âm thanh ở định dạng WAV. Bạn chỉ cần biết tên tệp của âm thanh bạn muốn phát và quyết định xem bạn có muốn macro đợi trong khi âm thanh phát hay không.

Đây là một ví dụ:

Public Declare Function sndPlaySound Lib "winmm.dll" _

Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long

Sub PlayWavFile(WavFileName As String, Wait As Boolean)

If Dir(WavFileName) = "" Then Exit Sub ' no file to play

If Wait Then ' play sound before running any more code

sndPlaySound WavFileName, 0

Else ' play sound while code is running

sndPlaySound WavFileName, 1

End If

End Sub

Sub TestPlayWavFile()

PlayWavFile "c:\foldername\soundfilename.wav", False

MsgBox "This is visible while the sound is playing..."

PlayWavFile "c:\foldername\soundfilename.wav", True

MsgBox "This is visible after the sound is finished playing..."

End Sub