EXCEL利用VBA播放WAV声音文件

来源:互联网 时间:2026-02-24 09:56:39 作者:

如果用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声音文件。

相关推荐