使用Excel2000单元中的ExcelApp.Caller

我正在写一个使用XLAutomationAddin实现自定义Excel函数的Excel插件。

在Excel2000单元中,可以使用ExcelApplication.Caller属性确定调用自定义函数的ExcelRange。

但是, Excel2000.pas typelib的定义说我需要使用

 property ExcelApplication.Caller[Index: OleVariant; lcid: Integer]: OleVariant; 

无论我尝试什么,我都无法得到这个工作,因为Excel不断拒绝任何我input的参数。
我知道我可以input0LOCALE_USER_DEFAULTlcid ,但是Excel对于Index参数需要什么?

解决scheme是将ExcelApplication转换成OleVariant。

像这样:

 unit ExcelHelper; .... implementation var Excel: ExcelApplication; {global var in unit} function Caller: ExcelRange; var ExcelAsVar: OleVariant; begin try ExcelAsVar:= Excel.Application; Result:= IUnkown(ExcelAsVar.Caller) as ExcelRange; except Result:= nil; end; {try} end;