日期:2014-05-16  浏览次数:21375 次

怎么在winform窗体中嵌入office的word窗口?
我用axWebBrowser控件,可是每次打开的word的时候会提示打开还是保存,相当于浏览器下载提示窗口,怎么避免这种情况?我想直接在窗体中显示word。听说word2003没有这种情况,但我的Office是2010版本的


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;
using System.Reflection;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
      
        private Object oDocument; 
        public Form1()
        {
            InitializeComponent();
            this.axWebBrowser1.NavigateComplete2 += new AxSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.axWebBrowser1_NavigateComplete2);
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Closed += new System.EventHandler(this.Form1_Closed);   
        }
  
        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "Browse";
            openFileDialog1.Filter = "Office   Documents(*.doc,  *.xls,   *.ppt)|*.doc;*.xls;*.ppt";
            openFileDialog1.FilterIndex = 1;   
        }

        public void Form1_Closed(object sender, System.EventArgs e)
        {
            oDocument = null;
        }   
    

        private void button1_Click(object sender, EventArgs e)
        {
            String strFileName;
            //Find the Office document.
            openFileDialog1.FileName = "";
            openFileDialog1.ShowDialog();
            strFileName = openFileDialog1.FileName;

            //If the user does not cancel, open the document.
            //Document doc = new Document();
            //doc.SaveAs();

       &n