"Toma Marinov" <To*********@di scussions.micro soft.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
Hello and thank you for your answer !
At the begining I thought that this was the problem, but when I process
DocumentComplet ed event, I saw that the word document was loaded very
fast.
After that on button.click event I try to acces DocumentStream or
DocumentText properties...Bu t they are null, ""...:o((
I'll continue to examine this situation...
Apologies, I actually missed that it was a *word* document you were trying
to access.
If you look here:
http://msdn.microsoft.com/library/de...w/Overview.asp
you will see that the WebBrowser control is an ActiveX document container,
and that while it normally hosts MSHTML (to render HTML), it can also host
other types of document.
Note this remark:
"Because WebBrowser objects are ActiveX objects, the WebBrowser objects can
host objects other than HTML documents. Check for the type of document you
are hosting."
and this remark concerning the WebBrowser's Document property:
"When other document types are active, such as a Microsoft Word document,
this property returns the document automation object of that document. For
Word documents, this would be the Document object."
However, the WebBrowser wrapper in VS 2005 exposes a Document property that
is specifically an HtmlDocument. You can overcome this by importing the
ActiveX Microsoft WebBrowser control, in which the Document property is of
type object. Using the following code I successfully cast this to a Word
document in DocumentComplet e:
private void axWebBrowser1_D ocumentComplete (object sender,
AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event e)
{
mshtml.HTMLDocu ment htmldoc;
Microsoft.Offic e.Interop.Word. Document worddoc;
if (this.axWebBrow ser1.Document is Microsoft.Offic e.Interop.Word. Document) {
MessageBox.Show ("Got a word document");
}
if (this.axWebBrow ser1.Document is mshtml.HTMLDocu ment)
{
MessageBox.Show ("Got an HTML document");
}
}
.... So, how do you get at this property while using the new wrapper? My
first thought was to cast the ActiveXInstance property to an
AxSHDocVw.AxWeb Browser, but that doesn't appear to work. Ideas anyone?
Tim
Read my tech blog:
http://www.itwriting.com/blog