Accessing the MSHTML object in IE

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

How can I access the MSHTML object in Internet Explorer, from my app?
I don't want to use the IE Control and put it in my app. I want to be
able to do things with the opened document in the allready started IE.
 
Hi,

Add a reference to Microsoft HTML object library in the com tab.

Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object, ByVal e
As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
Dim doc As mshtml.HTMLDocumentClass

doc = CType(AxWebBrowser1.Document, mshtml.HTMLDocumentClass)

RichTextBox1.Text = doc.documentElement.innerHTML
End Sub

Ken
 
depending upon what you need to do with the underlying HTML, you can
also use one of the other document classes...

a friendly warning: these COM classes *change* the underlying source in
subtle ways (capitalizing, adding spaces, trimming trailing ";"
characters in styles, etc.

here's another code snippet

'get the IHTMLDocument2 object
Dim htmldoc2 As mshtml.IHTMLDocument2
htmldoc2 = CType(WebBrowser1.Document.DomDocument,
mshtml.IHTMLDocument2)

'get the IHTMLTextRange object
Dim textrange As mshtml.IHTMLTxtRange =
CType(htmldoc2.selection.createRange, mshtml.IHTMLTxtRange)
 
Nikolay,

AFAIK will this part not go.
I want to be
able to do things with the opened document in the allready started IE.

However you can open IE using the shdocvw and instance from that
InterenetExplorer instead of axwebbrowser. Be aware that you get than a much
more limited amount of methods, which is not documentated.

'Add from Project menu a reference from
'COM Microsoft Internet Controls
Public Class testIE
Public Shared Sub main()
Dim a As New SHDocVw.InternetExplorer
a.Visible = True
a.Navigate2("http://msdn.microsoft.com/")
End Sub
End Class

You can than use code as Ken and Stand sure showed.

I hope this helps, although it is not the answer you expected.

Cor
 
I need an access to the default IE browser, which every user can start,
not one created using axwebbrowser or shdocvw.
I guess my prog should be an plugin for IE, but I don't have idea how
to write one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top