Who can help me, please?
I'm getting crazy as the code underneath sometimes works and sometimes doesn't. I haven't got a clue when it is working and when it doensn't ...
It lookslike that VBA is loosing its focus sometimes. It is not getting the right innerhtml and it is not closing the IE-window at objie.quit. But sometimes it just does... I have been playing around with the sleep-function as i thought it might have to do with not being ready yet with downloading the informatiion. However, it doesnt't make any difference.
Your help is very much appreciated.
Saskia
I'm getting crazy as the code underneath sometimes works and sometimes doesn't. I haven't got a clue when it is working and when it doensn't ...
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")
Debug.Print ele.Value
If ele.Value = "Deal" Then
ele.Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
pbnInternet = objIE.document.body.innerHTML
End If
Next ele
objIE.Quit
pos = InStr(1, pbnInternet, "")
If pos > 0 Then pbnInternet = Mid(pbnInternet, pos + 5)
End Function
It lookslike that VBA is loosing its focus sometimes. It is not getting the right innerhtml and it is not closing the IE-window at objie.quit. But sometimes it just does... I have been playing around with the sleep-function as i thought it might have to do with not being ready yet with downloading the informatiion. However, it doesnt't make any difference.
Your help is very much appreciated.
Saskia