Option Explicit
Public Sub GetStudentData()
Dim objIE As Object
Dim ws As Worksheet
Dim iLastRow As Long
Dim iRow As Long
Const sURL As String = "[URL]http://www.damascusuniversity.edu.sy/ol/ems/[/URL]"
Const sSearchText As String = "<!-- show results for this student -->"
Const sPause As String = "00:00:02"
Const sPageTimeout As String = "00:00:45"
Dim dtTimeout As Date
Dim iFound As Long
Dim sTemp As String
Set ws = ThisWorkbook.Sheets("Sheet1")
ws.Columns("B").ClearContents
iLastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
Set objIE = CreateObject("InternetExplorer.Application")
For iRow = 2 To iLastRow
Do While IsEmpty(ws.Cells(iRow, 2))
dtTimeout = Now() + TimeValue(sPageTimeout)
With objIE
.Visible = True [COLOR=green]' change this to False if you don't want to watch IE in action
[/COLOR] .Silent = True
.Navigate (sURL)
Do Until .ReadyState = 4 Or Now() > dtTimeout
DoEvents
Loop
If Now() < dtTimeout Then
Application.Wait Now() + TimeValue(sPause) [COLOR=green]' pause before filling in the form and pressing the button
[/COLOR] .document.all.studentId.Value = ws.Cells(iRow, 1)
.document.all.submitCardInfo.Click
dtTimeout = Now() + TimeValue(sPageTimeout)
On Error Resume Next ' in case page not available
iFound = InStr(.document.body.outerHTML, sSearchText)
On Error GoTo 0
Do Until iFound > 0 Or Now() > dtTimeout
On Error Resume Next ' in case page not available
iFound = InStr(.document.body.outerHTML, sSearchText)
On Error GoTo 0
DoEvents
Loop
If Now() < dtTimeout Then
ws.Cells(iRow, 2) = .document.body.innerText
End If
End If
End With
Loop
Next iRow
objIE.Quit
Set objIE = Nothing
End Sub