我不知道你是怎么用的,我在Delphi6 + OfficeXP中试过,用
http://www.delphibbs.com/delphibbs/dispq.asp?lid=786011
中的GotoDocEnd函数没有问题,如果你觉得两个Table粘在一起的
话就加一个空行就是了.试验的Word文件新建后,插入了一个Table,然后保存.
// 打开文档
procedure TForm1.Button5Click(Sender: TObject);
begin
OpenDoc(WordApp,WordDoc,'e:/doc2.doc');
end;
// 在文档末尾添加一个Table
procedure TForm1.Button10Click(Sender: TObject);
var
DefaultTableBehavior,AutoFitBehavior : OleVariant;
begin
DefaultTableBehavior := wdWord9TableBehavior;
AutoFitBehavior := wdAutoFitFixed;
GotoDocEnd(WordApp);
WordApp.Selection.TypeParagraph;
WordDoc.Tables.Add(WordApp.Selection.Range ,5,2,DefaultTableBehavior,AutoFitBehavior);
end;
// Open Doc 函数
procedure OpenDoc(WrdApp: TWordApplication; var WrdDoc: TWordDocument; FileName: string);
var
FName, ConfirmConvert, ReadOnly, AddToRecentFile, PwdDoc, PwdTemp: OleVariant;
Revert, WritePwdDoc, WritePwdTemp, Format, Encoding, Visible: OleVariant;
begin
WrdApp.Connect;
WrdApp.Visible := True;
FName := FileName;
ConfirmConvert := EmptyParam;
ReadOnly := EmptyParam;
AddToRecentFile := EmptyParam;
PwdDoc := EmptyParam;
PwdTemp := EmptyParam;
Revert := EmptyParam;
WritePwdDoc := EmptyParam;
WritePwdTemp := EmptyParam;
Format := EmptyParam;
Encoding := EmptyParam;
Visible := EmptyParam;
WrdDoc.ConnectTo(WrdApp.Documents.Open(FName, ConfirmConvert, ReadOnly, AddToRecentFile, PwdDoc, PwdTemp,
Revert, WritePwdDoc, WritePwdTemp, Format, Encoding, Visible));
end;