procedure TForm1.Button1Click(Sender: TObject);
var
TextRange:range;
SearchText,Wrap:Olevariant;
i,k:byte;
begin
TextRange := wordapplication1.ActiveDocument.Content;
SearchText :=Edit1.text;
Wrap:=wdFindStop;
//查找
TextRange.Find.Execute(SearchText, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, Wrap,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
TextRange.SetRange(TextRange.End_,TextRange.End_);//关标定位到找到的文本的之后
wordapplication1.ActiveDocument.Tables.Add(TextRange,2,2, EmptyParam, EmptyParam);
for i:=1 to 2 do
for k:=1 to 2 do
begin
wordapplication1.ActiveDocument.Tables.Item(1).Cell(i, k).Width:=200;
wordapplication1.ActiveDocument.Tables.Item(1).Cell(i, k).Height:=24;
wordapplication1.ActiveDocument.Tables.Item(1).Cell(i, k).Range.InsertAfter('Cell,'+intToStr(i)+','+intToStr(k));
end;
end;