Reload browser html content in vba


I have a code in vba that opens a page of ie. I get the html and then I pulse a bonton that is in a popup. That button adds new code to the html of the page, so when added later, I can not access to press another popup button. I need to reload the browser code without reloading the page to not lose that popup and press it. I put the code below. It is a bit urgent, if possible, of course. Thank you very much.

Sub openExplorer()
' --------------------------- VARS IE ---------------------
Dim ie As Object
Dim objDocucment As mshtml.HTMLDocument
Dim State As Integer

'--------------------------- PROGRAM OPEN_IE ---------------------
State = 0
Do Until State = 4
    State = ie.readyState
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "https://www1.anyWeb.html"
ie.Visible = True
Application.Wait (Now + TimeValue("00:00:15"))
 Write #1, "----- Print all html : "
For Each body In ie.Document.getElementsByTagName("body")
    Write #1, body.innerHTML
For Each body In ie.Document.getElementsByTagName("button")
    If botones.Title = "Si" Then
         botones.Click 'This button add new code html 
    End If
' ----> Load new code html in browser here.

Application.Wait (Now + TimeValue("00:00:05"))

Set ie = Nothing
End Sub
asked by Moses91 09.04.2018 в 18:03

1 answer


You should wait for the page to load (also after the button).

Option Explicit
Public Sub openExplorer()
    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "https://www1.anyWeb.html"
        While .Busy Or .readyState < 4: DoEvents: Wend


        While .Busy Or .readyState < 4: DoEvents: Wend

    End With
End Sub
answered by 15.07.2018 в 11:26