views:

67

answers:

1

Trying to get this line to work

 mshtml.IHTMLDocument2 doc2 = webBrowser1.Document as mshtml.IHTMLDocument2;

but getting the error message

Error 10 Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.IHTMLDocument2' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

Which I haven't come across before. I've done some searching and it seems many others have gotten that line to work? Any help / explanations greatly appreciated! Thanks!

+1  A: 

Try something like the following:

MSHTML.IHTMLDocument2 currentDoc =
    (MSHTML.IHTMLDocument2)webBrowser1.Document.DomDocument;

I found the reference online at: HtmlDocument.DomDocument - at MSDN

Adam Markowitz
Thanks, that did it!
evan