function OpenWordDocument(const AFileName: String; //uses Comobj
AControl: TCustomMemo): Boolean;
var
NewDoc: Variant;
V: OleVariant;
begin
try
try
V := CreateOleObject('Word.Application');//建立自动化对象
NewDoc :=V.Documents.Open(AFileName); //打开指定文件
NewDoc.Content.Copy; //拷贝到剪贴板
AControl.Lines.Clear;
AControl.PasteFromClipboard; //粘贴
NewDoc.Close; //关闭Word文件
finally
V.Quit; //释放自动化对象
end;
Result := True;
except
Result := False;
end;
end;
此文章由 http://www.ositren.com 收集整理 ,地址为:
http://www.ositren.com/htmls/68692.html