delphi自动化错误Excel 2010
有谁知道为什么下面的代码不适用于Excel 2010( 家庭和小型企业Office版 )?
procedure TForm1.Button1Click(Sender: TObject); var rango : OleVariant; ExcelObject : TExcelApplication; ExcelWorksheet : TExcelWorksheet; LCID : integer; begin try ExcelObject := TExcelApplication.Create (self); LCID := LOCALE_USER_DEFAULT; ExcelObject.Workbooks.Add(EmptyParam, LCID); ExcelWorksheet := TExcelWorksheet.Create(ExcelObject); ExcelWorksheet.ConnectTo(ExcelObject.Worksheets.Item [1] as _Worksheet); rango := ExcelWorksheet.Range['B2','B2']; rango.Font.size := 16; rango.Font.Bold := True; rango.Value2 := 'test'; ExcelObject.Visible[lcid] := true; except on e: exception do showmessage(e.message); end; end;
在添加工作簿时显示“未注册的类”exception:“ExcelObject.Workbooks.Add(EmptyParam,LCID);”
这适用于Office 2010 Proffesional Edition(和较旧的Office Edition),但不适用于Home and Small Business Edition 2010 Edition。