|
-
Jul 18th, 2008, 12:15 AM
#1
Thread Starter
New Member
[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:
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 ?
-
Jul 18th, 2008, 08:22 AM
#2
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
Last edited by stanav; Jul 18th, 2008 at 08:27 AM.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jul 19th, 2008, 03:44 AM
#3
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|