如何用C#获取获取WORD文件页数,谢谢

解决方案 »

  1.   

    .NET对WORD操作,总有不尽人意的地方.
      

  2.   

    如果.NET中包括一个对Office操作的类而不用引用Office就好了...
      

  3.   

    MODI maybe helpful
    Coming with MS Office 2003, the MODI library offers you an easy but effective way to integrate Optical Character Recognition (OCR) functionality into your own applications.
    ref:
    http://www.codeproject.com/csharp/modi.asp
      

  4.   

    Knight94(愚翁) ( )的纯英文教学
      

  5.   

    try..http://www.chinaaspx.com/Comm/Dotnetbbs/Showtopic.aspx?Forum_ID=31&id=14241
      

  6.   

    我把代码贴出来看下..
    (自己没有测试过..楼主可以参考一下..)using System; 
    using System.Threading; 
    using System.Reflection; 
    using Microsoft.Office.Interop.Word; namespace DocPageCounter 

       /// <summary> 
       /// Summary description for Class. 
       /// </summary> 
       class PageCounter 
       { 
          /// <summary> 
          /// The main entry point for the application. 
          /// </summary> 
          [STAThread] 
          static void Main(string[] args) 
          { 
             // 
             // TODO: Add code to start application here 
             // 
             ApplicationClass WordApp = new ApplicationClass();                  // give any file name of your choice.  
                    object fileName = "E:\\abc\\test.doc";  
                    object readOnly = false;  
                    object isVisible = true;                 //  the way to handle parameters you don't care about in .NET  
                object missing = System.Reflection.Missing.Value;                 //   Make word visible, so you can see what's happening  
                    //WordApp.Visible = true;  
                    //   Open the document that was chosen by the dialog  
                Document aDoc = WordApp.Documents.Open( 
                                        ref fileName, 
                                            ref missing,ref readOnly, ref missing, 
                                            ref missing, ref missing, ref missing, 
                                  ref missing, ref missing, ref missing, 
                                  ref missing, ref isVisible,ref missing, 
                                  ref missing, ref missing);                 WdStatistic stat = WdStatistic.wdStatisticPages ;  
                    int num =  aDoc.ComputeStatistics(stat,ref missing);  
                    System.Console.WriteLine ("The number of pages in doc is {0}",  
                                              num);  
                System.Console.ReadLine();       } 
       }