"Unable to set FormulaArray property"

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

"Unable to set FormulaArray property"
Excel Delphi 
Larry X


Serious Developer


Posts: 34
Joined: 2011-04-22
I get this error message above when I try to

App.Selection.FormulaArray := '='+Formula;

where

Formula := 'MyTestFunction('+'a1:a10'+')';

And of course I am able to enter the formula manually, as well as use the same code shown above to enter a similar function implementing the same algorithm but written in VBA.

Your input much appreciated.
Posted 27 Apr, 2011 10:00:54 Top
Dmitry Kostochko


Add-in Express team


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

Please try to test the following code:

try
  App.Selection.FormulaArray := '='+Formula; 
except
  App.Selection.FormulaArray := '='+Formula; 
end;
Posted 27 Apr, 2011 11:18:29 Top
Larry X


Serious Developer


Posts: 34
Joined: 2011-04-22
Thank you so much. It worked!

Any suggestions on how to prevent the need for that workaround? FWIW, I can set the formula with the function as long as the parameter list of the function is empty. If I put in parameters, then the workaround you posted is necessary.

Best,

Larry
Posted 27 Apr, 2011 11:30:51 Top
Dmitry Kostochko


Add-in Express team


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

Frankly speaking I don't know exactly why a without-parameters function works at first attempt while a with-parameters function does not. But I know for sure that Excel does not load UDF add-ins immediately at start up, it loads them on request (e.g. when the user enters your formula). So, I can assume that something prevents Excel from running a with-parameters function right away and we need to kick it once again.
Posted 27 Apr, 2011 12:07:30 Top