How to stop webbrowser

Viewed 286

Using the URL as an example which illustrates the problem, using Webbrowser embedded within a cell, upon DocumentComplete the specific URL continues to load additional content which causes the DocumentComplete to fire, again and again, have tried Webbrowser.stop without success. Any suggestions greatly appreciated.

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 Answers

Here is Suggestion from my side,

Please create BAT file with following code

taskkill /F /IM iexplore.exe /T

'its an example for IE, you can modify depending on the browser

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

Hope this will help you, please feel free to post your suggestions

Regards, Kadhir Nataraj

Related