非得用Server控件,很麻烦的,我勉强写出来了,没实验。
对应的VBA代码如下:
Selection.EndKey Unit:=wdStory,Extend:=wdMove
Selection.InsertFile FileName:="1.doc", Range:="", ConfirmConversions:= False, Link:=False, Attachment:=False
转换过来就麻烦了,因为Delphi要求的是Var ,必须定义变量,同时必须填够参数
var
wd_Story, wd_Move: OleVariant;
l_Range, l_ConfirmConversions, l_Link, l_Attachment: OleVariant;
begin
//Selection.EndKey Unit:=wdStory,Extend:=wdMove
wd_Story := wdStory;
wd_Move := wdMove;
WordApplication1.Selection.EndKey(wd_Story, wd_Move);
// Selection.InsertFile FileName:="1.doc", Range:="", ConfirmConversions:= False, Link:=False, Attachment:=False
l_Range := '';
l_ConfirmConversions := False;
l_Link := False;
l_Attachment := False;
WordApplication1.Selection.InsertFile('C:/1.doc', l_Range, l_ConfirmConversions, l_Link, l_Attachment);
end;
唉!使用Ole就容易了
var
Word_Handle: OleVariant;
begin
Word_Handle.Selection.EndKey(unit := wdStory, Extend := wdMove);
Word_Handle.Selection.InsertFile(FileName := '1.doc', Range := '', ConfirmConversions := False, Link := False, Attachment := False);
希望是对的。