vba怎样将音频文件先读入内存,然后再播放内存中的文件?

 我来答
一朵山茶Yunater
2018-11-27 · TA获得超过727个赞
知道小有建树答主
回答量:2416
采纳率:67%
帮助的人:430万
展开全部
Option ExplicitPublic Declare Function sndPlaySound32 _ Lib "winmm.dll" _ Alias "sndPlaySoundA" ( _ ByVal lpszSoundName As String, _ ByVal uFlags As Long) As LongSub PlayTheSound(ByVal WhatSound As String)
If Dir(WhatSound, vbNormal) = "" Then
' WhatSound is not a file. Get the file named by
' WhatSound from the Windows\Media directory.
WhatSound = Environ("SystemRoot") & "\Media\" & WhatSound If InStr(1, WhatSound, ".") = 0 Then
' if WhatSound does not have a .wav extension,
' add one.
WhatSound = WhatSound & ".wav"
End If
If Dir(WhatSound, vbNormal) = vbNullString Then
Beep ' Can't find the file. Do a simple Beep.
Exit Sub
End If
Else
' WhatSound is a file. Use it.
End If

sndPlaySound32 WhatSound, 0&
End Sub
追问
因为要反复的播放这个提示音,所以希望先将文件读到内存中。这个每次调用都是要读硬盘的吧?
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
克克卡7
2018-11-27 · TA获得超过2284个赞
知道大有可为答主
回答量:4801
采纳率:84%
帮助的人:579万
展开全部
如果你的OK.wav只是读文字的话,可以试一下Excel的语音。
Sub speak_ok()
Application.Speech.Speak ("OK")
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式