stopping automatic computation

Sep 28, 2012 at 8:36 PM

Hi Keith,


 I have a strange issue. It would be very kind of you to comment on it.

I am using your addin where i first create the AddinX object which looks something like the following 

static AddinX xai_create_handle( Function12().Arg().Uncalced().category().FunctionHelp() );

then the actual c++ function (lets call it Cfunc() )is called which does the computation.

The computation takes a little time and eventually creates a object. The object handle is the output of the Cfunc().

In excel whenever i hit the little funciton wizard button it opens up the GUI with the function arguemts listed. Now as I am trying to input the arguments of the function in that GUI box the control goes through the Cfunc() routine trying to do the computation.  

As a result even before i try to put in all the arguments Cfunc() gets computed resulting in a lot of exceptions (which i throw from inside my code when the arguments are not correct).

Also this behavior kind of slows down everything becuase the Cfunc() is trying to computed unnecessary number of times.

I thought the .Uncalced() is supposed to stop this behaviour from happening, but surely I am wrong.

I have automatic computation switched off in excel options but even then this behaviour happens.

All I want is the the function to compute only when I hit "ok" button of the GUI or when i hit enter.

Is there a way to achieve this ?




Sep 28, 2012 at 8:44 PM

inline bool in_function_wizard(void)
       return !ExcelX(xlfGetTool, OPERX(4), OPERX(_T("Standard")), OPERX(1));

Lets you check if your function is being called from the function wizard.

Sep 30, 2012 at 1:41 PM
Edited Sep 30, 2012 at 1:51 PM

Hi Keith,


 thanks for the reply. so where should i put this inline function ? in the same file which contains the static AddinX object is it ?

and how will it work such that when i am inside the function wizard and only when i press "ok" my Cfunc() (mentioned in the above example ) gets computed. 

should i have something like below



           if( in_function_wizard()) { then return 0;}

           else{ do actual computation} }


but this does not look correct. maybe i am making some mistake ?

Sep 30, 2012 at 3:47 PM