如何停止浏览器

时间:2018-11-09 18:00:00

标签: excel vba excel-vba webbrowser-control

使用URL作为说明问题的示例,使用嵌入在单元格中的Webbrowser,在DocumentComplete上,特定的URL继续加载其他内容,这导致DocumentComplete触发,一次又一次地尝试Webbrowser.stop失败。任何建议,不胜感激。

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim xURL As String
    xURL = "https://investorshub.advfn.com/"
    Application.Speech.Speak "Starting Look Up", Speakasync:=True, Purge:=True
    WebBrowser1.Silent = True
    WebBrowser1.Navigate (xURL)
    End
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    WebBrowser1.Stop
    Application.Speech.Speak " Look Up Completed ", Speakasync:=True, Purge:=True
    End
End Sub

1 个答案:

答案 0 :(得分:-2)

这是我的建议,

请使用以下代码创建BAT文件

Dim Filepath As String Filepath = "C:\user\folder\..." ' Full path of the BAT file Call Shell(Filepath & "\test.bat " & Filepath) ' replace the "test.bat" with your file name

以IE为例,您可以根据浏览器进行修改

{{1}}

希望这会对您有所帮助,请随时发布您的建议

关于, 卡迪尔·纳塔拉杰(Kadhir Nataraj)