procedure TFrmCertificate_Sample.Word2000Instrument(var FTable: Table);
var
OleWhat,OleWhich,OleCount,OleName:OleVariant;
FRow,I:Integer;
FLevel:Integer;
begin
OleWhat:=wdGoToBookmark; OleName:='Instrument';
OleWhich:=emptyenum; OleCount:=emptyenum;
Word2000.Selection.GoTo_(OleWhat,OleWhich,OleCount,OleName);
FLevel:=Word2000.Selection.Tables.Item(1).NestingLevel;
if FLevel>1 then
Word2000.Selection.Tables.Item(1).Delete;
//----------------
if MyFrame.Suffix='测试报告' then Exit;
Word2000Table(FTable,100,9,FRowCount+1,5,False);
with FTable do
begin
Cell(1,1).Range.Text:='名称';
Cell(1,2).Range.Text:='规格型号';
Cell(1,3).Range.Text:='测量范围';
Cell(1,4).Range.Text:='不确定度/准确度';
Cell(1,5).Range.Text:='证书编号';
//------------------填写数据-------------
FRow:=2;
for I:=1 to StoreGrid.RowCount-1 do
begin
if StoreGrid.Cells[0,I]<>'' then
begin
Cell(FRow,1).Range.Text:=StoreGrid.Cells[1,I];
Cell(FRow,2).Range.Text:=StoreGrid.Cells[2,I];
Cell(FRow,3).Range.Text:=StoreGrid.Cells[3,I];
Cell(FRow,4).Range.Text:=StoreGrid.Cells[4,I];
Cell(FRow,5).Range.Text:=StoreGrid.Cells[5,I];
FRow:=FRow+1;
end;
end;
end;//end table
end;
--------
procedure TFrmCertificate_do.Word2000ReplaceText(FSection:Boolean;OldText,
ReplaceText: String);
var
OleForword,OleRelaceOption:OleVariant;
OleFindText,OleReplaceText:OleVariant;
begin
OleForword:=wdForward;
OleRelaceOption:=wdReplaceAll;
OleFindText:=OldText;
OleReplaceText:=ReplaceText;
if FSection then
Word2000.Selection.Sections.Item(1).Headers.Item(1).Range.Find.ExecuteOld(
OleFindText,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,
OleForword, EmptyParam,EmptyParam,OleReplaceText,OleRelaceOption)
else
Word2000.Selection.Range.Find.ExecuteOld(OleFindText,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,OleForword, EmptyParam,EmptyParam,
OleReplaceText,OleRelaceOption);
end;
以上都是成功的函数代码。。。,如果出现请检查你的DELPHI是不是出问题了。