D
Doe
I've been trying this for months. Doesn't work.
I've used the code in this article,
http://support.microsoft.com/kb/311288/en-us, HOW TO: Invoke the Find,
View Source, and Options Dialog Boxes for the WebBrowser Control from
Visual Basic .NET.
This code worked in VB.Net 2003 but not in VB.Net 2005.
Specifically this doesn't work... (all code is from article)
Private Function GetDocument() As mshtml.HTMLDocument
Try
Dim htm As mshtml.HTMLDocument = AxWebBrowser1.Document
GetDocument = htm
Catch
Throw (New Exception("Cannot retrieve the document from the
WebBrowser" + _
"Control: " + Err.GetException().Message))
End Try
End Function
I get an error message of can't cast WebBrowser1 to mshtml.HTML
Document. In VB.Net 2003, the browser was AxWebBrowser1, in 2005 it has
changed and is WebBrowser1 (for the first instance).
This code also does not work...
Public Sub ViewSource()
Dim cmdt As IOleCommandTarget
Dim o As Object
Try
cmdt = CType(GetDocument(), IOleCommandTarget)
cmdt.Exec(cmdGUID,
Convert.ToUInt32(MiscCommandTarget.ViewSource), _
Convert.ToUInt32
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT), o, o)
Catch
Throw (New Exception(Err.GetException().Message))
End Try
End Sub
If I replace GetDocument() (which didn't work, see above), with
WebBrowser1.Document, it says can't cast WebBrowser1.Document to
IOleCommandTarget.
Frankly, I didn't understand this code very much in the first place.
But I have tested it in VB.Net 2003 and it works. In 2005 it
doesn't. The browser has changed.
I am wondering if anyone knows how to make it work?
Maybe the codes/addresses changed too as in...
Private cmdGUID As New Guid(&HED016940, -17061, _
&H11CF, &HBA, &H4E, &H0, &HC0, &H4F, &HD7, &H8, &H16)
Or maybe it's something else.
Basically clueless here.
Any help appreciated.
Marnie
I've used the code in this article,
http://support.microsoft.com/kb/311288/en-us, HOW TO: Invoke the Find,
View Source, and Options Dialog Boxes for the WebBrowser Control from
Visual Basic .NET.
This code worked in VB.Net 2003 but not in VB.Net 2005.
Specifically this doesn't work... (all code is from article)
Private Function GetDocument() As mshtml.HTMLDocument
Try
Dim htm As mshtml.HTMLDocument = AxWebBrowser1.Document
GetDocument = htm
Catch
Throw (New Exception("Cannot retrieve the document from the
WebBrowser" + _
"Control: " + Err.GetException().Message))
End Try
End Function
I get an error message of can't cast WebBrowser1 to mshtml.HTML
Document. In VB.Net 2003, the browser was AxWebBrowser1, in 2005 it has
changed and is WebBrowser1 (for the first instance).
This code also does not work...
Public Sub ViewSource()
Dim cmdt As IOleCommandTarget
Dim o As Object
Try
cmdt = CType(GetDocument(), IOleCommandTarget)
cmdt.Exec(cmdGUID,
Convert.ToUInt32(MiscCommandTarget.ViewSource), _
Convert.ToUInt32
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT), o, o)
Catch
Throw (New Exception(Err.GetException().Message))
End Try
End Sub
If I replace GetDocument() (which didn't work, see above), with
WebBrowser1.Document, it says can't cast WebBrowser1.Document to
IOleCommandTarget.
Frankly, I didn't understand this code very much in the first place.
But I have tested it in VB.Net 2003 and it works. In 2005 it
doesn't. The browser has changed.
I am wondering if anyone knows how to make it work?
Maybe the codes/addresses changed too as in...
Private cmdGUID As New Guid(&HED016940, -17061, _
&H11CF, &HBA, &H4E, &H0, &HC0, &H4F, &HD7, &H8, &H16)
Or maybe it's something else.
Basically clueless here.
Any help appreciated.
Marnie