procedure TForm1.startword;
begin
  if (wordapplication.Documents.Count <> 0 ) then
  begin
    messagedlg('请先关闭word!', mterror, [mbok], 0);
    exit;
  end;  try
    wordapplication.connect;
  except
    messagedlg('word 没有正确安装', mterror, [mbok], 0);
    abort;
  end;
  wordapplication.visible := true;
  wordapplication.caption := 'delphi automation';
end;

解决方案 »

  1.   

    最好关掉瑞星,金山等病毒防火墙。procedure TForm1.CloseWord;
    var
      savechanges, originalformat, routedocument: olevariant;
    begin
      savechanges := wdSaveChanges;
      originalformat := unassigned;
      routedocument := unassigned;
      try
        wordapplication.quit(savechanges, originalformat, routedocument);
        wordapplication.disconnect;
      except
        on e: exception do
      begin
        showmessage(e.message);
        wordapplication.disconnect;
      end;
      end;
    end;