View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JoeLiuzzo JoeLiuzzo is offline
external usenet poster
 
Posts: 4
Default How to obtain current selection using C++

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,<al ltypes);
(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.