[RESOLVED] [2008] Error with MSHTML
Hello
I am trying to grab the current document from the web browser control and converts it to the strong typed mshtml.HTMLDocument class with this function:
Code:
Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
But I get the following error:
Quote:
Runtime errors might occur when converting 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument'.
coming from the " wb.document ". Did I forget to add a reference ? other than the mshtml that is ?
Re: [2008] Error with MSHTML
You need to get the DomDocument from the Document. Also, there's no HTMLDocument class in mshtml namespace. You probably are after
the IHTMLDocument (there's also IHTMLDocument2, IHTMLDocument3, IHTMLDocument4 and IHTMLDocument5 calsses that you can use)
Code:
Private Function GetCurrentWebDoc() As mshtml.IHTMLDocument
Try
Return DirectCast(wb.Document.DomDocument, mshtml.IHTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Re: [2008] Error with MSHTML
looks like it's working but I'll test a few more times before marking this thread as resolved :) Thank you for your help and the details