Group:  Microsoft Excel » microsoft.public.excel.sdk
Thread: How to get XLL to insert formula into a cell? (xlcFormula?)

How to get XLL to insert formula into a cell? (xlcFormula?)
Chris <chris[ at ]chrisbird.com> 11/25/2008 10:28:36 AM
I am trying to get an XLL to insert a formula into the current active
cell (the formula text is autogenerated by a dialog which is selected
via a menu within Excel).
I have tried to use the xlcFormula command (Excel 2003) however it
always fails saying that the formula text is invalid.

cpp_xloper setCellOp;
cpp_xloper setCellOp_Value(L"=SUM(B2:B5)");
if (xlretSuccess != setCellOp.Excel(xlcFormula, setCellOp_Value))
return xlretFailed;

If the '=' is removed and replaced with text then the call works fine,
however if '=' is the first character it always fails.

Is xlcFormula the correct call for inserting a formula?

Thanks,

Chris.
Re: How to get XLL to insert formula into a cell? (xlcFormula?)
Chris <chris[ at ]chrisbird.com> 11/25/2008 12:07:20 PM
Ok, this appears to be due to the cell/range reference in the text.
Anyone have a clue how you encode a cell/range reference so the call
to xlcFormula works?

Thanks,

Chris.

On Nov 25, 10:28 am, Chris <ch...[ at ]chrisbird.com> wrote:
[Quoted Text]
> I am trying to get an XLL to insert a formula into the current active
> cell (the formula text is autogenerated by a dialog which is selected
> via a menu within Excel).
> I have tried to use the xlcFormula command (Excel 2003) however it
> always fails saying that the formula text is invalid.
>
> cpp_xloper setCellOp;
> cpp_xloper setCellOp_Value(L"=SUM(B2:B5)");
> if (xlretSuccess != setCellOp.Excel(xlcFormula, setCellOp_Value))
>    return xlretFailed;
>
> If the '=' is removed and replaced with text then the call works fine,
> however if '=' is the first character it always fails.
>
> Is xlcFormula the correct call for inserting a formula?
>
> Thanks,
>
> Chris.

Re: How to get XLL to insert formula into a cell? (xlcFormula?)
"Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)com> 11/25/2008 8:44:58 PM
Hi Chris

Try R1C1 style references. I think that should do it. It is a little odd
that in some cases the default Excel reference style is not the default C
API style, but it's all part of the rich tapestry of Excel down the ages.

Regards

Steve Dalton


"Chris" <chris[ at ]chrisbird.com> wrote in message
news:7eb37364-b7a3-4d68-8caf-c8a07e511f32[ at ]w3g2000yqc.googlegroups.com...
Ok, this appears to be due to the cell/range reference in the text.
Anyone have a clue how you encode a cell/range reference so the call
to xlcFormula works?

Thanks,

Chris.

On Nov 25, 10:28 am, Chris <ch...[ at ]chrisbird.com> wrote:
[Quoted Text]
> I am trying to get an XLL to insert a formula into the current active
> cell (the formula text is autogenerated by a dialog which is selected
> via a menu within Excel).
> I have tried to use the xlcFormula command (Excel 2003) however it
> always fails saying that the formula text is invalid.
>
> cpp_xloper setCellOp;
> cpp_xloper setCellOp_Value(L"=SUM(B2:B5)");
> if (xlretSuccess != setCellOp.Excel(xlcFormula, setCellOp_Value))
> return xlretFailed;
>
> If the '=' is removed and replaced with text then the call works fine,
> however if '=' is the first character it always fails.
>
> Is xlcFormula the correct call for inserting a formula?
>
> Thanks,
>
> Chris.


Re: How to get XLL to insert formula into a cell? (xlcFormula?)
Chris <chris[ at ]chrisbird.com> 11/26/2008 8:52:00 AM
Steve,

Thanks, that did the trick.

Chris.


On Nov 25, 8:44 pm, "Steve Dalton" <NOsteveSPAM(at)NOeigensysSPAM(dot)
com> wrote:
[Quoted Text]
> Hi Chris
>
> Try R1C1 style references.  I think that should do it.  It is a little odd
> that in some cases the default Excel reference style is not the default C
> API style, but it's all part of the rich tapestry of Excel down the ages.
>
> Regards
>
> Steve Dalton
>
> "Chris" <ch...[ at ]chrisbird.com> wrote in message
>
> news:7eb37364-b7a3-4d68-8caf-c8a07e511f32[ at ]w3g2000yqc.googlegroups.com...
> Ok, this appears to be due to the cell/range reference in the text.
> Anyone have a clue how you encode a cell/range reference so the call
> to xlcFormula works?
>
> Thanks,
>
> Chris.
>
> On Nov 25, 10:28 am, Chris <ch...[ at ]chrisbird.com> wrote:
>
>
>
> > I am trying to get an XLL to insert a formula into the current active
> > cell (the formula text is autogenerated by a dialog which is selected
> > via a menu within Excel).
> > I have tried to use the xlcFormula command (Excel 2003) however it
> > always fails saying that the formula text is invalid.
>
> > cpp_xloper setCellOp;
> > cpp_xloper setCellOp_Value(L"=SUM(B2:B5)");
> > if (xlretSuccess != setCellOp.Excel(xlcFormula, setCellOp_Value))
> > return xlretFailed;
>
> > If the '=' is removed and replaced with text then the call works fine,
> > however if '=' is the first character it always fails.
>
> > Is xlcFormula the correct call for inserting a formula?
>
> > Thanks,
>
> > Chris.- Hide quoted text -
>
> - Show quoted text -

Home | Search | Terms | Imprint
Newsgroups Reader