OLE访问Excel,提示错误“Variant does reference to an automation object”我的具体代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
mRow,mCol: Integer;
i,j: Integer;
ExcelApp,Sheet: Variant;
X: TStringList;
begin
ExcelApp.DisplayAlerts:=False;//禁止提示存盘
X:=TStringList.Create;
For i:=0 to FileListBox1.Items.Count-1 do
begin
ExcelApp.Workbooks.open(FileListBox1.Items[i]);//打开Excel文件
Sheet:=ExcelApp.Worksheets[1];//建立Excel的Sheet
ExcelApp.Worksheets[1].Activate;//激活Sheet1
X.Add(Sheet.Cells[2,15]);
end; ExcelApp.Workbooks.Close;
ExcelApp.Quit;end;错在哪里呐?
procedure TForm1.Button1Click(Sender: TObject);
var
mRow,mCol: Integer;
i,j: Integer;
ExcelApp,Sheet: Variant;
X: TStringList;
begin
ExcelApp.DisplayAlerts:=False;//禁止提示存盘
X:=TStringList.Create;
For i:=0 to FileListBox1.Items.Count-1 do
begin
ExcelApp.Workbooks.open(FileListBox1.Items[i]);//打开Excel文件
Sheet:=ExcelApp.Worksheets[1];//建立Excel的Sheet
ExcelApp.Worksheets[1].Activate;//激活Sheet1
X.Add(Sheet.Cells[2,15]);
end; ExcelApp.Workbooks.Close;
ExcelApp.Quit;end;错在哪里呐?
解决方案 »
- <顶着有分>将财经网站的每日美元汇率插入到数据库中,每天实时更新,怎么实现?
- 急救,请问如下报表用QuickRep打印如下效果
- 数据问题
- delphi7程序员开发指南的中文版现在有卖的吗?
- 在进销存系统中, 怎样把表单添加到数据库中,把刚添加到数据库中的表单进行修改?
- 哪里有免费的个人主页?
- 有没有无锡的公司招兼职程序员
- 我的机子运行了几个用bde连接数据库的程序,在delphi里就打开不了src了出现以下错误!
- 在delphi中如何使用netsend发送消息,点击按钮就发送消息
- 谁可以告诉我SDK的概念,请各位大虾赐教!
- Delphi
- 100分求教:进销存中销售单,退货单以及客户欠款之间的关系问题
ExcelApp:= CreateOleObject('Excel.Application');
ExcelApp.DisplayAlerts:=False;
//....