Search code examples
vb6browserouterhtml

VB6 webbrowser error can't get outerhtml property


I have old program was created it by VB6 and it was working good, I am using web browser control to load a webpage, then get the html inside a string, recently I received the below error message when I tried to load HTML code to a string variable, it's happen with big pages only.

enter image description here

My code as below

Dim html As String
Private Sub GetHtm_Click()
   WebBrowser1.Navigate (webVar)
   Do
        DoEvents
    Loop Until Not WebBrowser1.Busy
    html = WebBrowser1.Document.documentElement.outerHTML
End Sub

Solution

  • WebBrowser1.Document.documentElement.outerHTML only works in DocumentComplete Events.

    Private Sub WebBrowser1_DocumentComplete()
    
      html = WebBrowser1.Document.documentElement.outerHTML
    
    End Sub