09-10-2023, 07:26 AM
(08-10-2023, 09:31 PM)ALG2009 كتب : السلام عليكم
هل هذا الخطأ من عدم غلق الأكسيل أو ماذا؟
رسالة الخطأ
OLE error 800Ao033EC
الكود
كود :uses comobj private { Private declarations } ExcelFile,sheet : Variant; procedure TForm2.Button1Click(Sender: TObject); Var MaxRow, MaxCol,i,j:Integer; begin if OpenDialog1.Execute then ExcelFile := CreateOleObject('Excel.Application'); ExcelFile.visible:=0; ExcelFile.DisplayAlerts := False; ExcelFile.Workbooks.Open(OpenDialog1.FileName); sheet := ExcelFile.WorkSheets[1]; MaxRow := Sheet.Usedrange.Rows.count ; MaxCol := sheet.Usedrange.Columns.count; stringgrid1.RowCount:=maxRow+1; StringGrid1.ColCount:=maxCol+1; stringgrid1.Cells[1,i]:=excelfile.cells[i,1].value;; stringgrid1.Cells[2,i]:=excelfile.cells[i,2].value; stringgrid1.Cells[3,i]:=excelfile.cells[i,3].value; ExcelFile.workbooks.close; ExcelFile.quit; ExcelFile:=Unassigned; end;
كود :
procedure TForm1.Button1Click(Sender: TObject);
Var
MaxRow, MaxCol,i,j:Integer;
begin
if OpenDialog1.Execute then
ExcelFile := CreateOleObject('Excel.Application');
ExcelFile.visible:=0;
ExcelFile.DisplayAlerts := False;
ExcelFile.Workbooks.Open(OpenDialog1.FileName);
sheet := ExcelFile.WorkSheets[1];
MaxRow := Sheet.Usedrange.Rows.count ;
MaxCol := sheet.Usedrange.Columns.count;
stringgrid1.RowCount:=maxRow+1;
StringGrid1.ColCount:=maxCol+1;
For i := 1 to (maxRow+1) do begin
stringgrid1.Cells[1,i]:=excelfile.cells[i,1].value;;
stringgrid1.Cells[2,i]:=excelfile.cells[i,2].value;
stringgrid1.Cells[3,i]:=excelfile.cells[i,3].value;
end;
ExcelFile.workbooks.close;
ExcelFile.quit;
ExcelFile:=Unassigned;
end;
اللّهمّ فرّج أُموراً ضَاقت بها صُدورنا وعجزت بها حيلتنا وقلّ بها صَبرنا الّلهمّ أَسعِد قلوبنا بما أنتَ أعْلَمُ بِهِ مِنّا


![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)