Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当条件满足时,如何在VBA中播放wav声音文件?_Vba_Excel_Audio_Wav - Fatal编程技术网

当条件满足时,如何在VBA中播放wav声音文件?

当条件满足时,如何在VBA中播放wav声音文件?,vba,excel,audio,wav,Vba,Excel,Audio,Wav,我正在处理VBA表单,其中用户需要传递一个组合框条件,如下所示- Private Sub ComboBox4_AfterUpdate() Dim ws As Worksheet Set ws = Worksheets("PRODUCT") Fnsearch = ComboBox4.Value Set searchRange = ws.Range("B:B") Set foundCell = searchRange.Find(What:=Fnsearch,

我正在处理VBA表单,其中用户需要传递一个组合框条件,如下所示-

Private Sub ComboBox4_AfterUpdate()
    Dim ws As Worksheet
    Set ws = Worksheets("PRODUCT")

    Fnsearch = ComboBox4.Value
    Set searchRange = ws.Range("B:B")
    Set foundCell = searchRange.Find(What:=Fnsearch, After:=searchRange.Cells(searchRange.Cells.Count))

    If Not foundCell Is Nothing Then
        ' Doing some form work
        ' And want play notification sound here for user
    Else
        ' Want play notification sound here for user
        rslt = MsgBox("Kindly check product name which you typed." & vbCr & _
                      "Because this Item is not available in PRODUCT page." & vbCr & vbCr & _
                      "Kindly click Yes to Add Product or No to Discard.", vbYesNo, "Product not exists")
        If rslt = vbYes Then
            AddPartyA.Show
        End If
    End If
End Sub

您只需编写Beep即可添加声音。实际上,我想播放自定义声音。您看过PlaySound API了吗,您可以轻松地将其应用于VBA。我将从痛苦的经历中提出以下建议:永远不要使用“玩永恒循环”选项;永远不要给用户任何定制声音警报的机会——如果他们这样做了,你的办公室会听起来像个谷仓。你可以按照@SftAps Please your post添加你尝试的代码和由此产生的错误信息,而不是在评论中发布。