0 Replies - 237 Views - Last Post: 20 March 2012 - 02:37 PM Rate Topic: -----

#1 Peggy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 25-September 09

Removing alerts in a word document that is inside a web browser in c#

Posted 20 March 2012 - 02:37 PM

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?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1