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

Windows 2000
Delphi 5
BeitragVerfasst: Fr 07.05.04 09:42 
Hallo

ich habe folgendes Problem, ich öffne eine Excel Tabelle und trage bestimmte Werte in diese ein.

Jetzt möchte ich diese wieder schließen, aber da ich was verändert habe. Geht das nicht denn, ich muss erst die Datei speichern bevor ich sie schließe.

Leider hab ich keine Ahnung wie das geht.

Ich hoffe ihr könnt mir helfen.

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:
46:
47:
48:
49:
50:
unit Versuch2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtrls, ExtCtrls, ComObj, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

  Excel: OleVariant;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Excel := CreateOleObject('Excel.Application');

  Excel.Workbooks.open('c:\report.xls');

  Excel.Visible := True;

  Excel.Cells(2.2) := 'Hallo Bärbel';

end;

procedure TForm1.Button2Click(Sender: TObject);
begin

//Excel.Quit;    //fragt erst nach ob ich abspeichern will

 //Excel.Visible := False;  //geht aber dann ist nur des Fenster weg
end;

end.



Ich komme da echt nicht mehr weiter, würd mich freuen wenn ihr mir helfen könntet.

Danke

abi

_________________
Die lansamste Schnecke kommt auch irgendwann an.
hadd49
Hält's aus hier
Beiträge: 1

XP-Pro
Delphi6 und 7
BeitragVerfasst: Do 24.06.04 13:10 
Versuch' mal

Excel.DisplayAlerts := False;
Excel.Quit;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 24.06.04 13:32 
Ja, aber dann wird natürlich nicht gespeichert. Wenn das gewünscht ist, dann hilft vielleicht das weiter:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var flcid:integer;
    ws:variant;
[...]
flcid := GetUserDefaultLCID;
ws := Excel.WorkBooks[1].Sheets[1]; // Aktives WorkSheet
ws.SaveAs(Form1.ExportDialog.FileName,emptyParam,
           emptyParam,emptyParam,emptyParam,emptyParam,emptyParam,emptyParam,emptyParam, flcid)

_________________
We are, we were and will not be.
abi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 121

Windows 2000
Delphi 5
BeitragVerfasst: Do 24.06.04 13:36 
Hallo Gausi und hadd
danke das ihr mir schreibt.

Werde es mir in den nächsten paar Tagen hoffentlich anschauen können.

Ciao
abi

_________________
Die lansamste Schnecke kommt auch irgendwann an.