IE object not updating

ghadah

New Member
Joined
Feb 5, 2015
Messages
1
This is my first time to post in this Forum. Thank you for your help in advance.:)
I using vba in excel 2013 to get data from a webpage. I'm having a sync problem with my macro. Its entering user name and password and clicks submit button to transfer to a new page (confirmation page). Although the submit button is clicked and the confirmation page is shown, the IE.Document object is not updating with the 2nd page. However, when I inserted msgbox in between (after the click command and before calling the new objects for the confirmation page) it worked!!!:eeek:
I am using work PCs. The code works perfectly on my PC however when I tried to use it on other PCs this problem appeared. I have looked for days for a solution for that problem but did not find an answer.................

The portion of the code is:
Code:
Public Sub get_student_transcript()
    Application.ScreenUpdating = False

    Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
While IE.Busy
        DoEvents
    Wend
    IE.navigate "http://banner.aum.edu.kw:9020/pprd/bwlkoids.P_AdvIDSel"


    While IE.Busy
        DoEvents
    Wend

On Error Resume Next

 Err = 0
   IE.document.getElementById("SA_ID").Value = ID 'Inserts student ID
       While IE.Busy
        DoEvents
    Wend
 If Err <> 0 Then
 
    MsgBox ("Please enter your ID and password")
    IE.Quit
    End
End If
  
    
    Set ElementCol = IE.document.getElementsByTagName("INPUT")

' click submit
For Each btnInput In ElementCol
    If btnInput.Value = "Submit" Then
        btnInput.Click
        Exit For
    End If
Next btnInput

Do Until IE.readyState = 4
DoEvents
Loop
'------------------------------------------------------------------------------------
'If I insert msg box here it works
 'MsgBox (IE.document.getElementsByTagName("INPUT").Length)
'---------------------------------------------------------------------------------------------
'The confirmation PAGE (IE OBJECT NOT UPDATED)
    Set ElementCol = IE.document.getElementsByTagName("INPUT") 'Here the IE object is not updated

' loop through all 'input' elements and find the one with the value "Submit"
For Each btnInput In ElementCol
    If btnInput.Value = "Submit" Then
        btnInput.Click
        Exit For
    End If
Next btnInput

   While IE.Busy
        DoEvents
    Wend
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try changing:
Code:
Set ElementCol = IE.document.getElementsByTagName("INPUT")
to:
Code:
Do
    Set ElementCol = IE.document.getElementsByTagName("INPUT")
    DoEvents
Loop While ElementCol.Length = 0
 
Upvote 0

Forum statistics

Threads
1,224,614
Messages
6,179,906
Members
452,949
Latest member
beartooth91

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