Hello,
I'm trying to retrieve information from Internet. I'm opening the site, filling in a condition and press the button Deal. So far it works.
But then I'm trying to retrieve the information displayed on the website into VBA and sometimes that works and sometimes it doesn't.
It seems that most of the times VBA looses focus and Objie isn't valid anymore. objie.quit doesn't work either after the ele.click.
Can anybody help please?
I'm trying to retrieve information from Internet. I'm opening the site, filling in a condition and press the button Deal. So far it works.
But then I'm trying to retrieve the information displayed on the website into VBA and sometimes that works and sometimes it doesn't.
It seems that most of the times VBA looses focus and Objie isn't valid anymore. objie.quit doesn't work either after the ele.click.
Can anybody help please?
Code:
Function pbnInternet(Condition)
Dim objIE As Object, ele As Object
Dim pos As Integer
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.navigate "http://www.bridgebase.com/tools/dealer/dealer.php"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.all("i").Value = Condition
For Each ele In objIE.document.getElementsByTagName("input")
If ele.Value = "Deal" Then
ele.Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
pbnInternet = objIE.document.body.innerHTML
Debug.Print pbnInternet
objIE.Quit
pos = InStr(1, pbnInternet, "pre")
If pos > 0 Then pbnInternet = Mid(pbnInternet, pos + 5)
Exit For
End If
Next ele
End Function
Last edited: