How do you get a HTMLDocument into a webBrowser Object?

Let's say I had something like this in a forms load event.
    Dim xxx As HTMLDocument
    Set xxx = New HTMLDocument    
    xxx.body.innerHTML = "<body><p>what the hell</p></body>"

and on the form I have a webBrowser Object called wbMain.  How do I get the HTMLDocument into wbMain.  

I don't care if I have to save to a file first then navigate wbMain to it.  I just need to be able to dynamically generate html and get it into a webBrowser object?

Steve SiricaSenior Web Application EngineerAsked:
Who is Participating?
zzzzzoocConnect With a Mentor Commented:
Private Sub Command1_Click()
    'create document...
    Call wbDetails.Navigate("about:blank")
    'modify document...
    Call wbDetails.Document.write("<body style='font-family: verdana;'>")
    Call wbDetails.Document.write("<div>This actually works!</div>")
    Call wbDetails.Document.write("</body>")
    'retrieve document's body's html (if you'd like to save programmatically)...
    Debug.Print wbDetails.Document.body.outerHTML
    'prompt "save" dialog...
    Call wbDetails.Document.execCommand("SaveAs")
End Sub

Of course, if the HTMLBody is already created, you can directly modify it's outer/inner html via wbDetails.Document.Body.
Save your document to the harddrive. Then all you need to do is navigate it to the file:

Call wbMain.Navigate2("c:\test.html")
Steve SiricaSenior Web Application EngineerAuthor Commented:
Yeah, that's the easy part.  How do you save a HTMLDocument?
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Steve SiricaSenior Web Application EngineerAuthor Commented:
Never mind I just got it.
    wbDetails.Document.writeln ("<body style=""font-family: verdana;"">")
    wbDetails.Document.writeln ("<div>This actually works!</div>")
    wbDetails.Document.writeln ("</body>")

Does exactly what I was looking for, so the first person who answers with the above solution gets the points.
Éric MoreauSenior .Net ConsultantCommented:
To be fair, you should give points to Flembosa or ask for a refund.
Steve SiricaSenior Web Application EngineerAuthor Commented:
Thanks for playin...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.