Autor Beitrag
hauiclaudi
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 13.04.09 20:46 
Eine Anwendung die problemlos unter D7 läuft muss ich nun nach Delphi2009 portieren.
In D7 kann ich problemlos Exceltabbelle mit Werten füllen. Wieso funktioniert der gleiche Code in Delphi2009 nicht mehr? (VCL-Anwendung)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
unit haupt1;

interface

uses Variants, ComObj ...

procedure cxGridDBTableView4DBWKZAenderungerledigtProperties EditValueChanged(Sender: TObject);
begin

//*********** Excel füllen
Excel := CreateOleObject('Excel.Application');

// Open the Workbook
//Excel.Workbooks.Open(Pfad);

pfad := 'c:\temp\test.xls' ;
Excel.Workbooks.Open(Pfad);

Excel.Sheets[1].Name := 'Sheetname'; //Hierbei ist 1 das erste Sheet 2 das zweite usw.
Excel.Sheets['Übersicht'];
Excel.Sheets['Freigabe'].Cells[5,9].value := 'irgendein Wert' ;
end ;

Fehlermeldung:
undeclared identfier 'Name' at line 12
undeclared identfier 'Cells' at line 14
undeclared identfier 'value' at line 14

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Mo 13.04.09 20:47 
Crosspost im Entwickler-Forum: entwickler-forum.de/showthread.php?t=54551
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 13.04.09 21:12 
Du musst die Variable Excel auch als Variant deklarieren, bei mir funktioniert das dann problemlos. Als was hast du die deklariert? :gruebel:
hauiclaudi Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 13.04.09 21:22 
Hi Sebastian
Variable Excel habe ich als
ausblenden Delphi-Quelltext
1:
2:
var
Excel: Variant;

deklariert. Das Programm läuft zwar, Werte werden in Excel eingetragen, aber ich hab komischerweise im Editor nach wie vor den undeclared identifier name

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 13.04.09 21:26 
Ach soooo, du meinst links oben im Strukturfenster? Das ist normal, woher soll Delphi auch wissen was in so einem Variant drin steckt?

Und diese Fehleranzeige passiert auch sonst öfter einmal falsch. Solange sich das kompilieren lässt, ignoriere das einfach.

// EDIT:
Es gibt das IDE Fix Pack, das ein paar Fehler in der IDE behebt:
cc.embarcadero.com/Item/26283
hauiclaudi Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 13.04.09 22:01 
Es ist nur schlecht, wenn ca. 400 solcher Meldungen kommen, da viele verschiedenste Excel Sheets gefüllt werden. Dadurch geht D2009 ganz schön in die Knie. Kann man das irgendwie abschalten?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 13.04.09 22:02 
Natürlich:
Tools --> Optionen --> Editor-Optionen --> Code Insight --> Auf Pascal oben umschalten --> Fehlermarkierung

// EDIT:
Auf die deutsche Version von Delphi 2009 angepasst, auswendig wusste ich nur die englische von 2006. ;-)
hauiclaudi Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 13.04.09 22:11 
Super Sebastian
hat geklappt. Danke Dir.