?
Solved

How do you get a HTMLDocument into a webBrowser Object?

Posted on 2004-08-23
6
Medium Priority
?
644 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Steve Sirica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:Flembosa
ID: 11874799
Save your document to the harddrive. Then all you need to do is navigate it to the file:

Call wbMain.Navigate2("c:\test.html")
0
 
LVL 4

Author Comment

by:Steve Sirica
ID: 11874829
Yeah, that's the easy part.  How do you save a HTMLDocument?
0
 
LVL 4

Author Comment

by:Steve Sirica
ID: 11874896
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>")
    wbDetails.Refresh

Does exactly what I was looking for, so the first person who answers with the above solution gets the points.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11875041
To be fair, you should give points to Flembosa or ask for a refund.
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 2000 total points
ID: 11876246
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.
0
 
LVL 4

Author Comment

by:Steve Sirica
ID: 11881339
Thanks for playin...
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question