Open Excel WebBrowser

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hi
Anyone using the WebBrowser with Excel in DotNet 2005???

I have it working with the code below from MS but am trying to eliminate the
following behaviors

1)Stop FileDownload Dialog from Opening
2)Stop Open XML Dialog from Opening
3)Stop a separate Instance of Excel from starting

Thanks

this.axWebBrowser1.NavigateComplete2 += new
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2);

private void button1_Click(object sender, System.EventArgs e)

{

String strFileName;

//Find the Office document.

openFileDialog1.FileName = "";

openFileDialog1.ShowDialog();

strFileName = openFileDialog1.FileName;

//If the user does not cancel, open the document.

if (strFileName.Length != 0)

{

Object refmissing = System.Reflection.Missing.Value;

oDocument = null;

axWebBrowser1.Navigate(strFileName, ref refmissing, ref refmissing, ref
refmissing, ref refmissing);

}

}

public void axWebBrowser1_NavigateComplete2(object sender,
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)

{

Object o = e.pDisp;

oDocument = o.GetType().InvokeMember("Document", BindingFlags.GetProperty,
null, o, null);

Object oApplication = o.GetType().InvokeMember("Application",
BindingFlags.GetProperty, null, oDocument, null);

Object oName = o.GetType().InvokeMember("Name", BindingFlags.GetProperty,
null, oApplication, null);

MessageBox.Show("File opened by: " + oName.ToString());




}
 
Back
Top