procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
i,j,h,l,h2,l2: Integer;
ab: string;
ac: string;
ExcelApp,WorkBook,WorkSheet: Variant;
ExcelApp2,WorkBook2,WorkSheet2: Variant;
begin
if int(key)<>13 then
begin
//if int(key)= 32 then
// begin
// Label5.Caption :=Label5.Caption;
// ShowMessage(Label5.Caption);
// end
// else
// begin
Label5.Caption :=Memo1.Lines.Strings[Memo1.Lines.Count-1];
//end;
end
else
begin
ab:=Label5.Caption;
//Label5.Caption :='';
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := false;
WorkBook := ExcelApp.WorkBooks.Open(Edit1.Text);
ExcelApp.WorkSheets[1].Activate;
WorkSheet := WorkBook.WorkSheets.Item[1];
l :=ExcelApp.worksheets[1].Usedrange.columns.count;
h :=ExcelApp.worksheets[1].Usedrange.rows.count;
for i:=1 to h-1 do
begin
for j:= 1 to l-1 do
begin
if Memo1.Lines.Strings[Memo1.Lines.Count-1] = ExcelApp.Cells[i,j].Value then
begin
Memo2.Lines.Add('OK'); //////////////////////////// 有问题 ////////////////////////////////
ExcelApp2 := CreateOleObject( 'Excel.Application' );
ExcelApp2.Visible := false;
WorkBook2 := ExcelApp.WorkBooks.Open(Edit2.Text);
ShowMessage('145553');
ExcelApp2.WorkSheets[1].Activate; //有问题
WorkSheet2 := WorkBook2.WorkSheets.Item[1];
h2 :=ExcelApp2.worksheets[1].Usedrange.rows.count;
ShowMessage(inttostr(h2));
ExcelApp2.ActiveSheet.row.copy(ExcelApp.ActiveSheet.row[i].value);
// myRange1:=sheet.Range[sheet.cells[39,1],sheet.cells[79,16]];
// myRange2:=sheet.Range[sheet.cells[80,1],sheet.cells[120,16]];
//myRange1.Copy(myRange2) ;
continue;
end
else
begin
Memo2.Lines.Add('SN没有扫描到!');
end; continue;
end;
end;
end;
end;代码如上,提示的是这句;ExcelApp2.WorkSheets[1].Activate; 有问题。问题提示为:raised exception class EoLeException with message 'OLE error 800A03EC'.请各位大虾指教指教。
Shift: TShiftState);
var
i,j,h,l,h2,l2: Integer;
ab: string;
ac: string;
ExcelApp,WorkBook,WorkSheet: Variant;
ExcelApp2,WorkBook2,WorkSheet2: Variant;
begin
if int(key)<>13 then
begin
//if int(key)= 32 then
// begin
// Label5.Caption :=Label5.Caption;
// ShowMessage(Label5.Caption);
// end
// else
// begin
Label5.Caption :=Memo1.Lines.Strings[Memo1.Lines.Count-1];
//end;
end
else
begin
ab:=Label5.Caption;
//Label5.Caption :='';
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := false;
WorkBook := ExcelApp.WorkBooks.Open(Edit1.Text);
ExcelApp.WorkSheets[1].Activate;
WorkSheet := WorkBook.WorkSheets.Item[1];
l :=ExcelApp.worksheets[1].Usedrange.columns.count;
h :=ExcelApp.worksheets[1].Usedrange.rows.count;
for i:=1 to h-1 do
begin
for j:= 1 to l-1 do
begin
if Memo1.Lines.Strings[Memo1.Lines.Count-1] = ExcelApp.Cells[i,j].Value then
begin
Memo2.Lines.Add('OK'); //////////////////////////// 有问题 ////////////////////////////////
ExcelApp2 := CreateOleObject( 'Excel.Application' );
ExcelApp2.Visible := false;
WorkBook2 := ExcelApp.WorkBooks.Open(Edit2.Text);
ShowMessage('145553');
ExcelApp2.WorkSheets[1].Activate; //有问题
WorkSheet2 := WorkBook2.WorkSheets.Item[1];
h2 :=ExcelApp2.worksheets[1].Usedrange.rows.count;
ShowMessage(inttostr(h2));
ExcelApp2.ActiveSheet.row.copy(ExcelApp.ActiveSheet.row[i].value);
// myRange1:=sheet.Range[sheet.cells[39,1],sheet.cells[79,16]];
// myRange2:=sheet.Range[sheet.cells[80,1],sheet.cells[120,16]];
//myRange1.Copy(myRange2) ;
continue;
end
else
begin
Memo2.Lines.Add('SN没有扫描到!');
end; continue;
end;
end;
end;
end;代码如上,提示的是这句;ExcelApp2.WorkSheets[1].Activate; 有问题。问题提示为:raised exception class EoLeException with message 'OLE error 800A03EC'.请各位大虾指教指教。
解决方案 »
- TWordDocument调用word复制粘贴功能
- des 加密问题
- 请教在DBGrid中按回车数据就跳到下一个单元格的代码,参与者都有分得!
- 急问,interbase数据库导出问题,谢谢
- 现在女孩心里想着啥???????????????????????????????????????????????????????
- 我是考公务员,还是继续做程序员??
- 高分高分喽…… 请问大家都用什么组件做三层呢?给一个例子(在线等待)
- 在程序运行时如何改本程序的系统托盘图标
- 我在编一个读取MP3改名程序,高手帮忙看看我的代码。
- 求:数据库控件,可编写独立于BDE的数据库应用程序,无任何其它附加的DLL
- DelphiXe 使用OpenGL进行2D文字输出,乱码
- 怎样才能让dbgrideh或CXgrid插入新记录时,当前光标只能在新插入的行内移动?
WorkBook2 := ExcelApp2.WorkBooks.Open(Edit2.Text);
ShowMessage('145553');
ExcelApp2.WorkSheets[1].Activate; //有问题