Reputation: 1296
*Using HTML Object library with vba *(CAS is set as Browser instance (shdocvw))
Set HTMLDoc = CAS.document.frames("MainFrame").document 'pull the main frame
Do Until Not HTMLDoc Is Nothing
DoEvents
Loop
I dont think this is correct since, It will only set HTMLDoc one time, and if it is nothing, its going to keep looping itself over and over, checking for it to be something, but since it's only called once. A better way to go, imho, would be can check for an element and loop until the element exists, since the page can load, but my elements pulling from a DB take half a second longer or so. Im just not sure how to write the loop to keep setting the htmldoc, and then keep checking for an element within it to be not nothing. (The point is so even if my wait timer isnt waiting long enough, it should not proceed until the element exists)
Upvotes: 2
Views: 5885
Reputation: 166835
If you wanted to wait for a specific element:
Dim el As Object
Do
Set el = Nothing
On Error Resume Next
Set el = CAS.document.frames("MainFrame").document.getElementById("idHere")
On Error GoTo 0
DoEvents
Loop While el Is Nothing
You probably want to build in a maximum wait time though, so you don't loop endlessly if for some reason the element never appears.
Upvotes: 2