Autor Beitrag
abi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 121

Windows 2000
Delphi 5
BeitragVerfasst: Do 06.05.04 10:05 
Hallo

ich habe folgendes Problem, ich habe eine Excel datei auf die zugreife. Des klappt ja alles wunder bar, aber wenn ich jetzt meinen rechner runterfahre. Beschwert sich mein Rechner das ich diese Datei nicht geschlossen habe und frägt mich ob ich diese speichern will.

Ich brauch diese Datei nur als vorlage, damit man dann einen Bericht ausdrucken kann.

Denn Code habe ich hier im Forum gefunden.

Ich glaub nicht das der Falsch ist, sondern nur das was bestimmt fehlt.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
procedure TAutotest1.PrintClick(Sender: TObject);
var j: Integer;
begin

  try
     Excel := CreateOleObject('Excel.Application');
  except
     ShowMessage('Fehler beim Datei öffnen');
  end;
  Excel.Workbooks.open('C:\autotestreport.xls');


  Excel.Visible := True;

  Excel.Cells(6,2) := BustypToStr(Bustyp);
  Excel.Cells(7,2) := FamilieToStr(CANopenTyp);
  Excel.Cells(8,2) := AufloesungTypToStr(CANopen_AufloesungTyp);

  Excel.Cells(9,2) := '32';
  Excel.Cells(10,2) := '20 kBaud';

  if testauto.Autotest1.OfenCheck.Checked = True then begin
  Excel.Cells(11,2) := 'OK';
  end
  else begin
  Excel.Cells(11,2) := 'failure';
  end;
  Excel.Cells(12,2) := 'kommt noch';
  Excel.Cells(13,2) := 'kommt noch';

  //Fehler ausgabe
  for j := 1 to FehlerAnzahl do
  begin
  Excel.Cells(22 +j,1) := 'Position Error' + IntToStr(j);
  Excel.Cells(22 +j,2) := '1A1';    //ist nicht gut, besonders bei meheren
  test := Memo15.Lines[j-1];
  Excel.Cells(22+j,3) := test;
  end;

  Excel.Cells(6,5) := Date;
 Excel.Cells(7,5) := TimeToStr(time);

 Excel.Cells(9,5) := Edit1.Text;

end;



mercy

abi

_________________
Die lansamste Schnecke kommt auch irgendwann an.
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Do 06.05.04 10:54 
Das was du da machst ist nicht Ole Container, sondern Ole Automation. Sind zwei verschiedene Sachen.

Das was du brauchst ist der Schließbefehl den du an Excel schickst. Eventuell könnte es Excel.Close sein. Keine Ahnung. Aber Excel wird nichts schließen bevor es eine Änderung nicht speichert.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(
abi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 121

Windows 2000
Delphi 5
BeitragVerfasst: Do 06.05.04 10:58 
und wie speicher ich dann mein Datei.

Dann könnte ich diese auch schliessen oder.

mercy

_________________
Die lansamste Schnecke kommt auch irgendwann an.
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Do 06.05.04 12:09 
Ja, was glaubst du wie du die Datei ansprichst?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  //...
  try 
     Excel := CreateOleObject('Excel.Application'); 
  except 
     ShowMessage('Fehler beim Datei öffnen'); 
  end; 
  Excel.Workbooks.open('C:\autotestreport.xls'); 


  Excel.Visible := True; 

  Excel.Cells(6,2) := BustypToStr(Bustyp); 
  Excel.Cells(7,2) := FamilieToStr(CANopenTyp); 
  Excel.Cells(8,2) := AufloesungTypToStr(CANopen_AufloesungTyp); 
  //...


Da ist es. Das Wort "Excel" in deinem Code steht nicht für das Programm Excel, sondern ist eine Variable. Die Variable Excel zeigt auf die Datei. Cells ist kein Delphi Befehl, sondern der Excelbefehl. Du mußt also rausfinden mit welchen Befehl Excel seine Dokumente schließt. Öffnen kannst du sie mit Excel.Workbooks.open, jetzt mußt du nur noch rausfinden wie schließen.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(