logic to loop until web page element is not nothing

前端 未结 1 1425
悲&欢浪女
悲&欢浪女 2021-01-07 11:15

*Using HTML Object library with vba *(CAS is set as Browser instance (shdocvw))

Set HTMLDoc = CAS.document.frames(\"MainFrame\").document \'pull the main fra         


        
相关标签:
1条回答
  • 2021-01-07 11:38

    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.

    0 讨论(0)
提交回复
热议问题