Hey all
I'm left scratching my head. My stock broker is moving to a new website and I have to redo my excel macro to login and get some information from the new website.
I can't seem to find any code that will wait until the page/login form finishes loading.
Any ideas?
I've tried a bunch of variations of loops such as the ones below but nothing wants to wait for the page to finish loading.
Do While IE.ReadyState = 4: DoEvents: Loop
Do Until IE.ReadyState = 4: DoEvents: Loop
Here is my code so far:
I'm left scratching my head. My stock broker is moving to a new website and I have to redo my excel macro to login and get some information from the new website.
I can't seem to find any code that will wait until the page/login form finishes loading.
Any ideas?
I've tried a bunch of variations of loops such as the ones below but nothing wants to wait for the page to finish loading.
Do While IE.ReadyState = 4: DoEvents: Loop
Do Until IE.ReadyState = 4: DoEvents: Loop
Here is my code so far:
VBA Code:
Sub login()
Dim IE As Object
Dim objElement As Object
Dim objCollection, objCollection2 As Object
Dim n as Long
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://client.bnc.ca/nbdb/login"
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
n = 0
For Each itm In IE.document.all
If itm = "[object HTMLInputElement]" Then
n = n + 1
If n = 1 Then
itm.Focus 'Activates the Input box (makes the cursor appear)
itm.Value = "test"
End If
End If
Next
End Sub