Autor Beitrag
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mo 04.08.08 23:23 
Hallo,
beim steuern von excel über ole speichere ich mit
ausblenden Delphi-Quelltext
1:
Excel.ActiveWorkbook.SaveAs(filename);					

Wenn die datei aber schon existiert, soll sie ohne Abfrage einfach ersetzt werden. Sicher geht dass mit
ausblenden Delphi-Quelltext
1:
2:
if fileexists (filename) then deletefile (filename);
Excel.ActiveWorkbook.SaveAs(filename);



Aber es muss doch wohl noch eine Schönere Lösung geben? Weil Wenn der nun bei
ausblenden Delphi-Quelltext
1:
Excel.ActiveWorkbook.SaveAs(filename);					

abstürtzt, ist keine Version der Datei mehr da.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 04.08.08 23:41 
Moin!

user profile iconBoldar hat folgendes geschrieben:
Aber es muss doch wohl noch eine Schönere Lösung geben?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if fileexists(filename) then begin
  deletefile(backup_filename);
  RenameFile(filename, backup_filename);
end;
Excel.ActiveWorkbook.SaveAs(filename);
:nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Chemiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 194
Erhaltene Danke: 14

XP, Vista 32 Bit, Vista 64 Bit, Win 7 64 Bit
D7, BDS 2006, RAD Studio 2009+C++, Delphi XE2, XE3, VS 2010 Prof.
BeitragVerfasst: Mo 11.08.08 23:48 
Hallo Boldar,

einfach die Excel – Meldungen abstellen.

ausblenden Delphi-Quelltext
1:
2:
3:
Excel.DisplayAlerts := FALSE; // Meldungen  abstellen
Excel.ActiveWorkbook.SaveAs(filename);
Excel.DisplayAlerts := TRUE; // Meldungen wieder anstellen.

Wenn die Datei schon existiert wird sie ohne Nachfragen überschrieben.

Bis bald Chemiker