vrijdag 26 september 2008

Get HTML from Webbrowser Control

The following function will get the complete html source code from a webpage shown in the Webbrowser Control:

Public Function GetHTML(Web As WebBrowser) As String
  'declare variables
  Dim doc As HTMLDocument
  
  'Make sure the page has been completely loaded
  'if not wait
  Do
    DoEvents
  Loop Until Not Web.Busy
  
  Set doc = Web.Document
  
  'return the html
  GetHTML = doc.All(0).outerHTML
End Function