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:(
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Gaurish89

New Member
Joined
Apr 27, 2016
Messages
5
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
 

Gaurish89

New Member
Joined
Apr 27, 2016
Messages
5
Must add refrences: Microsoft Shell Controls and Automation and Microsoft Internet Controls
 

shaialo

New Member
Joined
May 1, 2019
Messages
1
Must add refrences: Microsoft Shell Controls and Automation and Microsoft Internet Controls
This didn't help, as I had both Microsoft Shell Controls and Automation and Microsoft Internet Controls marked already
 

Watch MrExcel Video

Forum statistics

Threads
1,102,706
Messages
5,488,423
Members
407,638
Latest member
brandynl

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top