如果获得某个页的文本?比如我要获得第一页的文本,也就是从开头到第一页最后一个字截止的文本

解决方案 »

  1.   

    Word.ApplicationClass wordApp=new ApplicationClass();
    object file=path;
    object nullobj=System.Reflection.Missing.Value;   
    Word.Document doc = wordApp.Documents.Open(
    ref file, ref nullobj, ref nullobj, 
    ref nullobj, ref nullobj, ref nullobj, 
    ref nullobj, ref nullobj, ref nullobj, 
    ref nullobj, ref nullobj, ref nullobj);doc.ActiveWindow.Selection.WholeStory();
    doc.ActiveWindow.Selection.Copy();
    IDataObject data=Clipboard.GetDataObject();
    txtFileContent.Text=data.GetData(DataFormats.Text).ToString();
    doc.Close();指定页,
    Function   GetPageRange(iPage   as   Integer)   as   Range   
      Set   GetPageRange   =   wd.ActiveDocument.Range(0,0)   
      Set   GetPageRange   =   GetPageRange.Goto(What:=wdGotoPage,   Name:=iPage)   
      Set   GetPageRange   =   GetPageRange.Goto(What:=wdGotoBook,   Name:="\Page")   
      End   Function
      

  2.   

    Function GetPageRange(iPage as Integer) as Range   
      Set GetPageRange = wd.ActiveDocument.Range(0,0)   
      Set GetPageRange = GetPageRange.Goto(What:=wdGotoPage, Name:=iPage)   
      Set GetPageRange = GetPageRange.Goto(What:=wdGotoBook, Name:="\Page")   
      End Function
    以这个方法什么都选不到。请检查一下是否有错。
    还有就是你这是DELPHI吧?