可以 这是代码
try
wordapplication1.Connect;
except
application.MessageBox('不能新建WORD文档!确认是否安装WORD。', '提示:', mb_ok);
abort;
end;
if trim(richedit1.Text) = '' then
showmessage('请输入插入的内容!')
else
begin
wordapplication1.Visible := false;
worddocument1.Sections.Item(1).footers.Item(1).Range.Text := '第一页';
worddocument1.Range.Insertafter(trim(richedit1.Text) + #13);
worddocument1.Range.Insertafter('考试单位___________ ');
worddocument1.Range.Insertafter('考试时间___________' + #13);
worddocument1.Range.ParagraphFormat.Alignment := wdalignparagraphcenter;
WordDocument1.Tables.add(worddocument1.Range(sstart, send), NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior);
worddocument1.Range.Font.Size := 14;
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add(' select * from subject ');
ADOQuery2.Open;
****iindex := 0;
for i := 0 to 8 do
begin
****iindex := ****iindex + 1;
WordDocument1.Range.InsertAfter(inttostr(****iindex) + '、' + Adoquery2.FieldValues['SubjectContent'] + #13);
WordDocument1.Range.InsertAfter(inttostr(****iindex) + '答案、' + Adoquery2.FieldValues['Subjectresult'] + #13);
adoquery2.Next;
end;
end;
wordapplication1.Visible := true;