uses ExtCtrls, ComObj
private
{ Private declarations }
StrExcelFile:String;
//
function ExcelSaveAsText(ExcelFile, TextFile: TFileName): Boolean;
const
xlText = -4158;
var
ExcelApp: OleVariant;
vTemp1, vTemp2, vTemp3: OLEVariant;
begin
Result := False;
try
ExcelApp := CreateOleObject('Excel.Application');
except
// Fehler beim öffnen von Excel...
// Error occured...
Exit;
end;
try
ExcelApp.Workbooks.Open(ExcelFile);
ExcelApp.DisplayAlerts := False;
vTemp3 := False;
vTemp2 := xlText;
vTemp1 := TextFile;
ExcelApp.ActiveWorkbook.SaveAs(vTemp1, vTemp2, vTemp3);
Result := True;
finally
ExcelApp.Quit;
ExcelApp := Unassigned;
end;
end;
Excel Mappe laden :
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
StrExcelFile := OpenDialog1.FileName;
ExcelSaveAsText(StrExcelFile,'C:\temp.txt') ;
Showmessage('Saved as '+StrExcelFile);
end;
end;
Keine Kommentare:
Kommentar veröffentlichen