如果用VBA代碼播放WAV聲音文件,可以用下面的代碼:
Private Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Sub PlayWavFile()
sndPlaySound32 "C:\Windows\Media\ding.wav", 0&
End Sub
運行上述代碼將播放“C:\Windows\Media”文件夾中的ding.wav聲音文件。