procedure TForm1.Button7Click(Sender: TObject);
var
fname: string;
MyWord: Variant;
begin
MyWord := CreateOleObject('Word.Basic');
if OpenDialog1.Execute then
fname := OpenDialog1.FileName;
if fname <> '' then
begin
MyWord.FileOpen(fname);
MyWord.AppShow;
fname := ExtractFiledir(Application.ExeName) + '/';
if FileExists(fname + 'zb.doc') then
begin
MyWord.TableSelectTable;
MyWord.EditCopy;
MyWord.FileOpen(fname + 'zb.doc');
MyWord.EndOfDocument;
MyWord.TableInsertTable;
MyWord.EditPaste;
MyWord.LineDown;
MyWord.TableDeleteRow;
MyWord.LineUp;
MyWord.TableDeleteRow;
MyWord.FileSave;
end;
MyWord.FileExit[2]; //退出MyWord程序
end;
end;
注:要合并的的各分表列数一致