I\'m trying to auto-complete a form on a website with values of an excel file.
Sub CommandButton1_Click()
Dim IE As Object
Dim objElement As Object
Dim objCo
Use a timed loop for element to be present
Option Explicit
'VBE > Tools > References:
' Microsoft Internet Controls
'
Public Sub CommandButton1_Click()
Dim ie As New InternetExplorer, t As Date, ele As Object
Const MAX_WAIT_SEC As Long = 10
With ie
.Visible = True
.Navigate2 "https://www.ryanair.com/be/nl/check-in"
While .Busy Or .readyState < 4: DoEvents: Wend
t = Timer
Do
On Error Resume Next
Set ele = .document.getElementById("username")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While ele Is Nothing
If ele Is Nothing Then Exit Sub
ele.Value = "resa@connections.be"
Stop
.Quit
End With
End Sub
Thank you for the quick answer! I just made small changes, as I received an error and I work with a button. It works like a charm now!
Public Sub CommandButton1_Click()
Dim ie As New InternetExplorer, t As Date, ele As Object
Const MAX_WAIT_SEC As Long = 10
t = Timer
With ie
.Visible = True
.Navigate2 "https://www.ryanair.com/be/nl/check-in"
While .Busy Or .readyState < 4: DoEvents: Wend
Do
On Error Resume Next
Set ele = .document.getElementById("username")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While ele Is Nothing
If ele Is Nothing Then Exit Sub
ele.Value = "resa@connections.be"
End With
End Sub