Const offSet = 5
Const READYSTATE_COMPLETE = 4
Private Sub CommandButton1_Click()
Dim i As Integer
Dim query As String
Dim inet As Object
Dim reponse As String
Dim erros As Integer
Dim nbRows As Integer
Set inet = CreateObject("InternetExplorer.Application" )
i = offSet
nbRows = 0
errors = 0
Do While True
If Sheets(1).Cells(i, 1) = "" Then
Exit Do
Else
nbRows = nbRows + 1
i = i + 1
End If
Loop
i = offSet
UserForm1.ProgressBar1.Min = 0
UserForm1.ProgressBar1.Max = nbRows
UserForm1.ProgressBar1.Value = 0
UserForm1.Label2.Caption = "0 %"
UserForm1.Show
For j = 1 To nbRows
query = Sheets(1).Cells(i, 1) & "¤" & Sheets(1).Cells(i, 2) & "¤" & Sheets(1).Cells(i, 3) & "¤" & Sheets(1).Cells(i, 4) & "¤" & Sheets(1).Cells(i, 5) & "¤" & Sheets(1).Cells(i, 6) & "¤" & Sheets(1).Cells(i, 7) & "¤" & Sheets(1).Cells(i, 8) & "¤" & Sheets(1).Cells(i, 9)
inet.Navigate ("http://gemseas.euro.med.ge.com/sales/crm/integration.asp?query=" & Replace(query, "&", "%26" ))
Do While Not inet.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
i = i + 1
Sheets(2).Cells(i - offSet, 1) = inet.Document.all.response.innerHTML
If Left(inet.Document.all.response.innerHTML, 6) = "Error:" Then
errors = errors + 1
End If
If Not UserForm1.Visible Then
UserForm1.Show
End If
UserForm1.ProgressBar1.Min = 0
UserForm1.ProgressBar1.Max = nbRows
UserForm1.ProgressBar1.Value = j
UserForm1.Label2.Caption = CStr(Format((j / nbRows) * 100, "##0.0" )) & " %"
Next
UserForm1.Hide
Sheets(2).Activate
MsgBox (i - offSet) & " lines exported with " & errors & " error(s)."
inet.Quit
Set inet = Nothing
End Sub
|