Using IHTMLDocument2 to format text in a webbrowser control

  • Thread starter Thread starter guyinkalamazoo3
  • Start date Start date
G

guyinkalamazoo3

Guest
Okay, I have been looking for a simple answer to this and trying to wrap my head around this interface. And yes, I am using Visual Basic and every solution I see is in C# or C++. All I am trying to do now is to format the font of my <h1> tag to Calibri and let me know if there is a better way to do this, however I know there will be some other style points I will need to include besides font.

So far I have this code in the form's load event.

And I get that "Object not set to reference" on the first line. Thanks for the information and btw, this html will be dynamically built and not derived from a standard URL.

Dim wbio As IHTMLDocument2 = TryCast(wbIOSummary.Document.DomDocument, IHTMLDocument2)
Dim wbhtml As New StringBuilder(wbio.body.outerHTML)
Dim wbioss As IHTMLStyleSheet = wbio.createStyleSheet("", 0)
wbioss.cssText = "h1 {font-family: calibri; }"

wbhtml.Append("<h1>INTAKE AND OUTPUT SUMMARY</h1>")

wbio.body.innerHTML = wbhtml.ToString




Brad Allison

Continue reading...
 
Back
Top