using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Prototype { public partial class Form1 : Form { object oDocument; Microsoft.Office.Interop.Word._Application wordApp; Microsoft.Office.Interop.Word._Document doc; public Form1() { InitializeComponent(); } private void button9_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Office Documents " + " " + "(*.doc, *.docx)|*.doc;*.docx"; openFileDialog1.FilterIndex = 1; System.Windows.Forms.HtmlDocument document; string sFileName; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); sFileName = openFileDialog1.FileName; if (sFileName.Length != 0) { oDocument = null; webBrowser1.Navigate(sFileName); document = webBrowser1.Document; wordApp = webBrowser1.Document; } } private void Form1_Load(object sender, EventArgs e) { /* if (sender.Equals(button9)) { openFileDialog1.Filter = "Office Documents " + " " + "(*.doc, *.docx)|*.doc;*.docx"; } else openFileDialog1.Filter = "Office Documents " + " " + "(*.doc, *.docx, *.xls, *.pptx, *.pdf, *.odt)|*.doc;*.docx;*.xls;*.pptx;*.pdf;*.odt"; ; openFileDialog1.FilterIndex = 1; */ } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { oDocument = webBrowser1.Document; } private void button8_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Office Documents " + " " + "(*.xls, *.xlsx)|*.xls;*.xlsx"; openFileDialog1.FilterIndex = 1; System.Windows.Forms.HtmlDocument document; string sFileName; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); sFileName = openFileDialog1.FileName; if (sFileName.Length != 0) { oDocument = null; webBrowser1.Navigate(sFileName); document = webBrowser1.Document; } } private void button7_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Office Documents " + " " + "(*.ppt, *.pptx)|*.ppt;*.pptx"; openFileDialog1.FilterIndex = 1; System.Windows.Forms.HtmlDocument document; string sFileName; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); sFileName = openFileDialog1.FileName; if (sFileName.Length != 0) { oDocument = null; webBrowser1.Navigate(sFileName); document = webBrowser1.Document; } } private void button10_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Office Documents " + " " + "(*.pdf)|*.pdf"; openFileDialog1.FilterIndex = 1; System.Windows.Forms.HtmlDocument document; string sFileName; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); sFileName = openFileDialog1.FileName; if (sFileName.Length != 0) { oDocument = null; webBrowser1.Navigate(sFileName); document = webBrowser1.Document; } } } }
My code uses a web browser to display a word, excel, and powerpoint. Unfortunately every time it tries to open it, an alert box first appears and asks if i want to save or open or cancel. How am i suppose to remove it?