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