Getting Method 'RegisterAsBrowser' error when doing IE automation: RRS feed

  • Question

  • I started getting an error while running my IE automation VBA script after moving over to a Windows 10 work laptop. I changed my code to use InternetExplorerMedium however I suddenly get this error now: Run-time error '-2147467259 (80004005)':
    Method 'RegisterAsBrowser' of object 'IWebBrowser2' failed. I'm not sure what's going on all of a sudden. I double checked my references and can't find an answer. Here is my code:

    Sub ImportS4()
    Dim IE As InternetExplorerMedium
    Dim IEDoc As Object
    Dim URL As String, username As String, password As String
    'This code creates new IE window and navigates to site
    Set IE = New InternetExplorerMedium
    IE.Navigate URL
    IE.Visible = True
    'Wait for IE load
    Do While IE.Busy = True: DoEvents: Loop
    Do Until IE.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    'Enter login information
    IEDoc = IE.Document
    IEDoc.getElementById("txtUserName").Value = username
    IEDoc.getElementById("txtPassword").Value = password
    End Sub

    Any help would be appreciated.

    Saturday, February 11, 2017 9:46 PM