[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do you get a HTMLDocument into a webBrowser Object?

Posted on 2004-08-23
6
Medium Priority
?
654 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

834 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