seanlhall
asked on
How can I display HTLM from a string in a WebBrowser Control?
I have a form with a Active X Webbrowser control. I want to display HTML from a string. I know how to display a web page and open a HTML file with out a problem. I found this code and it appears it is what I am looking for. The problem is I get an Error 'Run time Error 91 Object variable or With block variable not set. I have referenced MS HTML Object Library and MS Internet Controls. What am I missing?
Dim HTML As String
HTML = "<HTML>"
HTML = HTML & "<p> Preview my HTML string </p>"
HTML = HTML & "</HTML>"
Dim obj As HTMLDocument
Set obj = WebBrowserControlName.Docu ment
obj.body.innerHTML = HTML
Dim HTML As String
HTML = "<HTML>"
HTML = HTML & "<p> Preview my HTML string </p>"
HTML = HTML & "</HTML>"
Dim obj As HTMLDocument
Set obj = WebBrowserControlName.Docu
obj.body.innerHTML = HTML
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Jeff, you actually can create it from a string. I have done this a couple of times. The error the OP is getting in this case is because the WebBrowser's Document property returns Nothing if the control isn't first "initialized" when the form loads. This is done by having it navigate to a url or a blank page.
/Ron G.
/Ron G.
ok
ASKER
It works thanks.
...so I learned something new as well...
;-)
Jeff
;-)
Jeff
It's as if the web browser control can only read data from a (disk) "file".
c:\YourFolder\YourFile.HTM
So you could use code to save the string out to a temp file, then point the webbrowser at that...
The good news is that Access 2007-2010 format databases (.accdb format), can display Formatted HTML.
You must create a Memo Field and set the Text Format property to "Rich Text"
JeffCoachman