James Bond
James Bond

Reputation: 1

Internet Explorer to Edge Automation: Getting a run time error'-214767259(80004005)': Method ' Document' of object 'IWebBrowser2' failed

I am trying to open the Microsoft edge using internet explorer automations controller using the below code.

Here is the sub routine:

Sub OpenURL(ByVal SURL As String)
    Dim OIE As Object
    Dim htmlDoc as object
    Set OIE = CreateObject("Internet Explorer.Application")
    
    With OIE
        .Visible = True
        .Navigate ("microsoft-edge:" & SURL)
        
        Do While .ReadyState = 4
            DoEvents
        Loop
        Set htmlDoc = .Document 
        
        .Quit 
    End With
    
    Set OIE = Nothing 
End sub

Using this sub routine to test:

Sub testing()
    OpenURL "https://www.example.com"
End Sub

I got the run time error in this line of code:

Set htmlDoc = .Document

I am a newbie in vba scripting language, trying to build a scrapper to fetch the data from the website. I got this code from one of the blog https://www.devhut.net/vba-exploring-microsoft-edge/.

Please do let me know, what changes I have to make to store the html document . And also my plan is to interact with the dom as well by clicking on the button present in the website.If anyone can fix the code that will be very helpful.

Thanks in advance.

One humble request, I don't need a solution by using selenium because my organisation will not allow to implement it.

Upvotes: 0

Views: 71

Answers (0)

Related Questions