Error compiling simple UDF example

Add-in Express™ Support Service
That's what is more important than anything else

Error compiling simple UDF example
compiler does not like xlErrValue 
Laurent Guy


Serious Developer


Posts: 34
Joined: 2011-04-22
I get the compile error: <<<Undeclared identifier: 'xlErrValue'>>> when trying to Register ActiveX of the following simple example:

unit MyAutomationTest1_IMPL;

interface

uses
SysUtils, ComObj, ComServ, ActiveX, Variants, Office2000, adxAddIn, MyAutomationTest1_TLB, StdVcl;

type
TcoMyAutomationTest1 = class(TadxAddin, IcoMyAutomationTest1)
protected
function MyFunc(var Range: OleVariant): OleVariant; safecall;
end;

TAddInModule = class(TadxCOMAddInModule)
private
protected
public
end;

implementation

{$R *.dfm}

function TcoMyAutomationTest1.MyFunc(var Range: OleVariant): OleVariant;
begin
Result := 0;
case VarType(Range) of
varSmallint, varInteger, varSingle,
varDouble, varCurrency, varShortInt, varByte,
varWord, varLongWord, varInt64: Result := Range * 1000;
else
try
Result := Range.Cells[1, 1].Value * 1000;
except
Result := CVErr(xlErrValue);
end;
end;
end;

initialization
TadxFactory.Create(ComServer, TcoMyAutomationTest1, CLASS_coMyAutomationTest1, TAddInModule);

end.


Add-in Express Professional for D7 Pro under Windows XP Pro.

Best,

Larry
Posted 22 Apr, 2011 10:38:01 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Laurent,

The xlErrValue constant is declared in the Excel2000 unit. Please add Excel2000 to uses section of your module.
Posted 22 Apr, 2011 10:45:26 Top
Laurent Guy


Serious Developer


Posts: 34
Joined: 2011-04-22
AWESOME! works great!

another question on another thread.

Best,

Larry
Posted 22 Apr, 2011 10:49:11 Top
Laurent Guy


Serious Developer


Posts: 34
Joined: 2011-04-22
Thanks for all your help with this one.

Larry
Posted 22 Apr, 2011 13:41:11 Top
Larry X


Serious Developer


Posts: 34
Joined: 2011-04-22
What's the difference between Excel200 and ExcelXP in the 'uses' clause? Which one is more recent?
Posted 22 Apr, 2011 13:43:52 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Larry,

The Excel2000 file contains interfaces, constants and class wrappers of the Excel 2000 Object model. The ExcelXP file contains the same of the Excel 2002 Object model.
Posted 25 Apr, 2011 05:05:23 Top