我觉得你这样做没有必要吧,你只是要显示WORD文档相应的内容到指定的TextBox中,你可以直接采用OWC来操作这个WORD文档!这样你可以读出相应的内容就好..............

解决方案 »

  1.   

    当然我也给你你想要的参考,WORD转换成为HTML语言的资料
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using Office;namespace aspxWebcs
    {
    /// <summary>
    /// WordToHtml 的摘要说明。
    /// 首先要添加引用:Microsoft Word 9.0 Object Library
    /// </summary>
    public class WordToHtml : System.Web.UI.Page
    {
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
        Word.ApplicationClass word = new Word.ApplicationClass();
        Type wordType = word.GetType();
        Word.Documents docs = word.Documents;    // 打开文件
        Type docsType = docs.GetType();
        object fileName = "d:\\tmp\\aaa.doc";
        Word.Document doc = (Word.Document)docsType.InvokeMember("Open", 
        System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] {fileName, true, true});
              
        // 转换格式,另存为
        Type docType = doc.GetType();
        object saveFileName = "d:\\tmp\\aaa.html";
        //下面是Microsoft Word 9 Object Library的写法,如果是10,可能写成:
        //docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
         null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML});
        ///其它格式:
        ///wdFormatHTML
        ///wdFormatDocument
        ///wdFormatDOSText
        ///wdFormatDOSTextLineBreaks
        ///wdFormatEncodedText
        ///wdFormatRTF
        ///wdFormatTemplate
        ///wdFormatText
        ///wdFormatTextLineBreaks
        ///wdFormatUnicodeText
        docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
         null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatHTML});    // 退出 Word
        wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,
         null, word, null);
    }#region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }/// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load);
    }
    #endregion
    }
    }
      

  2.   

    你可以根据这个来进行修改,你要的功能我这边没有,仅仅给你一个参考吧
    如果你转化成为XML文档过后,可以通过XmlDocument来操作它,读出你想要的格式来吧
      

  3.   

    我认为直接将word内容直接导出到页面上指定textbox中,不太可能use VBA, add a macro in your winword, save the content to database, then pick out from your database send to textbox.
      

  4.   

    or save word to xml format, then handle
      

  5.   

    非常感谢各位:  1.首先use VBA, add a macro in your winword, save the content to database, then pick out from your database send to textbox.
    ”------我用这个办法已经实现了,但是我们头说处理个WORD文档不必用数据库,非让我用其它的办法
       2.or save word to xml format, then handle----这个我用过了,可是不知道,然后如何处理XML    liuyong_lll(孤醉)大哥“直接采用OWC来操作这个WORD文档!“这是个好的建议,我还没想到,就是不知道如何去用,能再指点一下吗     再次感谢各位,我觉得这个问题是挺有挑战性的,希望能再给我写指点,多谢了
      

  6.   

    非常感谢各位:  1.首先use VBA, add a macro in your winword, save the content to database, then pick out from your database send to textbox.
    ”------我用这个办法已经实现了,但是我们头说处理个WORD文档不必用数据库,非让我用其它的办法
       2.or save word to xml format, then handle----这个我用过了,可是不知道,然后如何处理XML    liuyong_lll(孤醉)大哥“直接采用OWC来操作这个WORD文档!“这是个好的建议,我还没想到,就是不知道如何去用,能再指点一下吗     再次感谢各位,我觉得这个问题是挺有挑战性的,希望能再给我写指点,多谢了
      

  7.   

    楼主好象把这个问题说的太严重了。
    OWC用的还是比较多,特别是做报表的时候
    我做的时候例子也没有,只有《Microsoft Office Web 组件对象模型参考》,楼主如果要的话,我就发给你
      

  8.   

    http://www.aspcool.com/lanmu/browse1.asp?ID=1058&bbsuser=XML