Einzelnen Beitrag anzeigen

rajuneon
(Gast)

n/a Beiträge
 
#1

EOleException bei Einbinden von Excel

  Alt 19. Mär 2009, 09:41
Hey!

Folgendes Problem:

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, Unit1, Menus, StdCtrls, ComObj;
  
var
  Excel : Variant;
  i : integer;

procedure TWerte.Wertespeichern1Click(Sender: TObject);
begin

Excel := CreateOleObject('Excel.Application');
Excel.Visible := true;
Excel.Workbooks.Add;
Excel.Sheets[1].Name := 'Wertetabelle';

for i := 0 to zeilencounter do
  begin
    Excel.Sheets['Wertetabelle'].Cells[i,0].value := StringGrid1.Cells[0,i];
    Excel.Sheets['Wertetabelle'].Cells[i,1].value := StringGrid1.Cells[1,i];
    Excel.Sheets['Wertetabelle'].Cells[i,2].value := StringGrid1.Cells[2,i];
    Excel.Sheets['Wertetabelle'].Cells[i,3].value := StringGrid1.Cells[3,i];
    Excel.Sheets['Wertetabelle'].Cells[i,4].value := StringGrid1.Cells[4,i];
    Excel.Sheets['Wertetabelle'].Cells[i,5].value := StringGrid1.Cells[5,i];
    Excel.Sheets['Wertetabelle'].Cells[i,6].value := StringGrid1.Cells[6,i];
    Excel.Sheets['Wertetabelle'].Cells[i,7].value := StringGrid1.Cells[7,i];
    Excel.Sheets['Wertetabelle'].Cells[i,8].value := StringGrid1.Cells[8,i];
    Excel.Sheets['Wertetabelle'].Cells[i,9].value := StringGrid1.Cells[9,i];
    Excel.Sheets['Wertetabelle'].Cells[i,10].value := StringGrid1.Cells[10,i];
  end;
führt zum Fehler:

"Exception der Klasse EOleException. Meldung: 'OLE-Fehler 800A03EC' Prozess wurde angehalten. Mit einzelner Anweisung oder Start fortsetzen"

Markiert und mit dem grünen Pfeil davor ( ) wird die erste Zeile der for-Schleife:
    Excel.Sheets['Wertetabelle'].Cells[i,0].value := StringGrid1.Cells[0,i]; Was ist falsch? Der Fehler sagt mir gar nichts Excel wird geöffnet, aber nichts hineingeschrieben und ich bekomme die Fehlermeldung.

Bei der Einbindung der OLE-Automation habe ich mich an DIESES Tutorial gehalten.

Vielen Dank im Voraus!
  Mit Zitat antworten Zitat