How to obtain current selection using C++

J

JoeLiuzzo

In a prior thread, I learned that the parameters passed to Excel via C++ are
essentially the same as the EXCEL macro language.

Wit this I've made great progress, but have run into a different problem. I
have the following sequence of steps, all being calls to Excel4 :

(xlcFormulaGoto,<xlResult>,1, <celladdress>);
(xlcSelectSpecial,<xlResult>,2,<currentregion>,<alltypes>);
(xlcSelection,<xlCurrRange>,0);

where the <> bracketed items are XLOPERs. (current region has value 5 and
alltypes value 23, as documented in the SelectSpecial macro function)

I confirmed that the first two steps work by returning to EXCEL after them
instead of continuing.

But the call to xlcSelection to obtain a reference to the region selected by
the SelectSpecial command is returning nonsense. The XLM docs indicate that
SELECTION() (on a macro sheet) normally dereferences, so to get the actual
reference you can use REFTEXT(). I can get everything to work using a macro
sheet, but cannot figure out how to do it in C++ code.

The content of the <xlCurrRange> XLOPER is of type xltypeRef, but the
reference itself is garbage.

Any suggestions would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top