消息框和声音播放同时进行-VBA

时间:2018-11-23 15:37:09

标签: excel vba userform

在下面的代码中,首先播放歌曲,然后显示消息。如何在下面的代码中同时显示消息框声音播放

Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean

Private Sub CommandButton1_Click()
    Call PlaySound("c:\windows\media\tada.wav", 0, SND_ASYNC Or SND_FILENAME)
    Msgbox "Process completed successfully."
End Sub

1 个答案:

答案 0 :(得分:0)

Private Declare PtrSafe Function PlaySound Lib "winmm.dll" _Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Boolean

Const SND_ASYNC = &H1

Private Sub CommandButton1_Click()
    Call PlaySound("c:\windows\media\tada.wav", 0, SND_ASYNC Or SND_FILENAME)
    Msgbox "Process completed successfully."
End Sub