TWordDocument;
TWordApplication;
try
if Wordapplication.Windows =nil then
Wordapplication.Connect;
//启动Word
except
Closeword;
MessageDlg('无法启动word,请确认word是否已安装', mtError, [mbOk], 0);
Abort;
end;
Wordapplication.Visible := false;
//先关闭Word的显示
WordApplication.Caption := 'Word Printer';
{Create newdo
cument}
Template :=do
tPath;
NewTemplate := False;
try
WordApplication.Documents.Add(Template, NewTemplate);
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
except
Closeword;
MessageDlg('打开模板'+DotPath+'失败,请检查模板文件是否存在', mtError, [mbOk], 0);
Abort;
end;
.....
what:=wdgotobookmark;
//以书签为定位对象
......
Wordapplication.Visible := True;
//打开Word的显示
Wordapplication.ActiveWindow.Activate;