Solved

How do you get a HTMLDocument into a webBrowser Object?

Posted on 2004-08-23
6
641 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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