procedure OpenDOC(fn:string;ed:TCustomRichEdit); //打开一个word文档,装到指定的richedit内
var App,count:Variant;
begin
try
App:=CreateOleObject('Word.Application');
except
MsgErrBox('打开WORD文档出现异常。');
Exit;
end;
App.Documents.Open(fn);
try
count:=App.Selection.StoryLength;
App.Selection.SetRange(0,count);
App.Selection.copy;
ed.Lines.Text :='';
ed.PasteFromClipboard;
App.Quit;
App:=Unassigned;
Count:=Unassigned;
except
App.Quit;
end;
end;