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
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吧?
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
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吧?