خطأ في جلب قيم من الأكسيل
#1
السلام عليكم

هل هذا الخطأ من عدم غلق الأكسيل أو ماذا؟

رسالة الخطأ
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;
الرد
#2
(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;
‏اللّهمّ فرّج أُموراً ضَاقت بها صُدورنا وعجزت بها حيلتنا وقلّ بها صَبرنا الّلهمّ أَسعِد قلوبنا بما أنتَ أعْلَمُ بِهِ مِنّا
[-] كل من 1 user says قال شكرا ل larbiparadox على المشاركة المفيدة
  • ALG2009
الرد
#3
جزاكم الله خير
لقد نُفذ دون أخطاء بارك الله فيك
[-] كل من 1 user says قال شكرا ل ALG2009 على المشاركة المفيدة
  • larbiparadox
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم