Autor Beitrag
PreMarT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

Work: Win XP ; Home: Win Vista 64-Bit

BeitragVerfasst: Mo 05.10.09 09:18 
Morgen Leute,

Hab da so kleine Probleme,

Also ich öffne eine Excel-Tabelle und will jegliche Fehler wie z.B. :

- Datei nicht vorhanden
- Datei wird benutzt
- keine *.xls Datei (durch falsches Auswählen oder Umbenennen von z.B. *.txt in *.xls)

Leider hab ich keine ahnung wie ich das in den folgenden Code rein packe...

ausblenden volle Höhe Delphi-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:
procedure TfrmMain.btnUebertragenClick(Sender: TObject);

begin
  _lcid := GetUserDefaultLCID;
  XLApp := TExcelApplication.Create(Self);
  try
    // Zum Server TExcelApplication verbinden
    XLApp.Connect;
    try
      // WorkBooks zur ExcelApplication hinzufügen
      XLApp.Workbooks.Open(c_sKartenAdresse , emptyParam,
        emptyParam,
        emptyParam, emptyParam, emptyParam, emptyParam, emptyParam,
        emptyParam, emptyParam, emptyParam, emptyParam, emptyParam,
        _lcid);
      // erstes WorkBook auswählen
      WorkBk := XLApp.WorkBooks.Item[1];
      // erstes WorkSheet definieren
      WorkSheet := WorkBk.WorkSheets.Get_Item(1) as _WorkSheet;

      call function LeseSpalteAnfang;

      //XLApp.Visible[0] := True;
    finally
      // Server disconnecten
      XLApp.Disconnect;
    end;

  finally
    XLApp.Quit;

  end;

end;



Und vielleicht könnt ihr mir sagen ob man meine Lösung zum öffnen der Excel-Tabelle aus verbessern kann
PreMarT Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

Work: Win XP ; Home: Win Vista 64-Bit

BeitragVerfasst: Mi 07.10.09 13:59 
Oder muss ich beim öffnen den *.xls Dateien schon überprüfen?

Bevor ich die sheets initialisiere? Wäre das einfacher?