ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to obtain current selection using C++ (https://www.excelbanter.com/excel-programming/422260-how-obtain-current-selection-using-c.html)

JoeLiuzzo

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.


All times are GMT +1. The time now is 05:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com