
Ich poste einfach mal den Code, denke der Fehler ist schon in der Suche, vielleicht findet jemand was
Code: Alles auswählen
procedure TForm1.Button1Click(Sender: TObject);
Var XLApp: OLEVariant;
x,y: word;
path: variant;
a : Integer;
suche : string;
begin
a:= StrToInt (Edit2.Text);
Label2.Caption:= ('Postleitzahl ' + IntToStr(a));
begin
XLApp := CreateOleObject('Excel.Application');
try
XLApp.Visible := False;
XLApp.DisplayAlerts := False;
path := edit1.Text;
XLApp.Workbooks.Open(Path);
for x := 1 to 2 do
begin
for y := 1 to 59998 do
begin
StringGrid1.Cells[x,y] := XLApp.Cells[y,x].Value;
end;
end;
begin
suche:= Edit2.Text;
for y:=0 to Stringgrid1.RowCount-1 do
If Stringgrid1.Cells[x,y]=suche
then
Label3.Caption := StringGrid1.Cells[2,y];
end;
finally
XLApp.Quit;
XLAPP := Unassigned;
end;
end;
end;