Run-time error '-2147467259(80004005)': Method 'Document' of object 'IWebBrowser2' failed

Gaurish89

New Member
Joined
Apr 27, 2016
Messages
5
My VBA was working fine on my personal laptop but now its not working on any system.
Everytime i am getting same error "Run-time error '-2147467259(80004005)': Method 'Document' of object 'IWebBrowser2' failed". When i click on Debug, it stops on following code line:

IE.Document.getElementById("login-form-username").Value = EditUN.Text 'Enter your username here


Below is the complete code:

Private Sub StartJira_Click()


'Open IE and hit JIRA Pearson Url
Set IE = CreateObject("InternetExplorer.Application")
IE.Silent = True
IE.Visible = True
IE.navigate UrlSelect.Value

JIRAUpdate.Hide

Do Until IE.readyState = READYSTATE_COMPLETE
Loop


IE.Document.getElementById("login-form-username").Value = EditUN.Text 'Enter your username here
IE.Document.getElementById("login-form-password").Value = EditPW.Text 'Enter your password here
IE.Document.getElementById("login").Click 'Hit login button

Do Until IE.readyState = READYSTATE_COMPLETE
Loop
Application.Wait (Now + TimeValue("0:00:30")) 'Wait



Dim X As Integer, Y As Integer

'Set numrows = number of rows of data.
NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
Y = NumRows + 1
'Select cell A2, *first line of data*.
Range("A2").Select
'Establish "For" loop to loop "numrows" number of times.
For X = 2 To Y

Set objCollection = IE.Document.getElementByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "searchString" Then

'Set text for search
objCollection(i).Value = Cells(X, 1).Value

Else
If objCollection(i).Type = "submit" And _
objCollection(i).Name = "" Then

' "Search" button is found
Set objElement = objCollection(i)

End If
End If
i = i + 1
Wend
objElement.Click ' click button to search

Application.Wait (Now + TimeValue("0:00:15")) 'Wait for 15 seconds

IE.Document.getElementById("comment-issue").Click 'click button to add comment
IE.Document.getElementById("comment").Value = Cells(X, 2).Value
IE.Document.getElementById("issue-comment-add-submit").Click

Set objElement = Nothing
Set objCollection = Nothing ' Clear search string

ActiveCell.Offset(1, 0).Select
Next



End Sub

Please Help:(
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The reason was session with IE got disconnected. Used following snippet after navigating to desired URL, helped me to get rid of the error:
Code:
Dim sh
 Dim eachIE As Object
 
Do
  Set sh = New Shell32.Shell
  For Each eachIE In sh.Windows
    If InStr(1, eachIE.LocationURL, UrlSelect.Value) Then
      Set IE = eachIE
      'IE.Visible = False  'This is here because in some environments, the new process defaults to Visible.
      Exit Do
      End If
    Next eachIE
  Loop
Set eachIE = Nothing
Set sh = Nothing
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,101
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top