这是我在网上查到的代码,不知道为什么无法显示在控件里,而是直接代开了word文档
请高手指点!
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 TestShowWordOnForm
{
    public partial class Form1 : Form
    {
        private Object oDocument;
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            String strFileName;
            openFileDialog1.FileName = "";
            openFileDialog1.ShowDialog();
            strFileName = openFileDialog1.FileName;
            if (strFileName.Length != 0)
            {
                Object refmissing = System.Reflection.Missing.Value;
                oDocument = null;
                axWebBrowser1.Navigate(strFileName, ref refmissing, ref refmissing, ref refmissing, ref refmissing);
            }
        }        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "Browse";
            openFileDialog1.Filter = "Office Documents(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt";
            openFileDialog1.FilterIndex = 1;        }        private void Form1_Closed(object sender, EventArgs e)
        {
            oDocument = null;
        }        private 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());        }
    }
}