Solved

How do you get a HTMLDocument into a webBrowser Object?

Posted on 2004-08-23
6
627 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
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 69

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now