procedure TForm1.initWord();
var template,newtemplate,itemindex:olevariant; begin try wordapplication1.Connect; except wordapplication1.Disconnect; messagedlg('请先安装Word软件!',mterror,[mbok],0); exit; end; newtemplate:=false; itemindex:=1; wordapplication1.Visible:=false; template:=ExtractFileDir(Application.Exename) +'模板.dot'; wordapplication1.Documents.Add(template,newtemplate,emptyparam,emptyparam); worddocument1.ConnectTo(wordapplication1.Documents.Item(itemindex)); end; procedure TForm1.unitWord(); begin worddocument1.Close; wordapplication1.Disconnect; end;