delphi控制excel的问题:Project Project1.exe raised exception class EOleSysError with m

  • 主题发起人 主题发起人 0452
  • 开始时间 开始时间
0

0452

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi控制excel的问题:Project Project1.exe raised exception class EOleSysError with message '无效的类别字符串'. Process stopped. Use Step or Run to continue. ( 积分: 100 )<br />unit Form1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, StdCtrls, Buttons, ComObj, ExcelXp, StrUtils;
...............
procedure TForm1.btn1Click(Sender: TObject);
var
ExcelApp: Variant;
begin
try
ExcelApp := CreateOleObject('ExcelApp.application');
except
application.MessageBox('系统中没有安装MS Excel软件!', '错误', MB_ICONERROR + MB_OK);
exit;
end;
try
ExcelApp.WorkBooks.add;
ExcelApp.WorkSheets[1].Activate;
..................
if not ExcelApp.ActiveWorkBook.Saved then //保存
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
finally
end;
end;

end.

问题如下:
为什么在ExcelApp := CreateOleObject('ExcelApp.application');处报错:Project Project1.exe raised exception class EOleSysError with message '无效的类别字符串'. Process stopped. Use Step or Run to continue.
请高手指点一二,谢谢!
 
ExcelApp := CreateOleObject(‘Excel.Application’);
 
接受答案了.
 

Similar threads

后退
顶部