Note that there are some explanatory texts on larger screens.

plurals
  1. POSelected range of Excel cells passed to an argument "as Variant" of a VBA function, then passed to an method of an ATL object in c++
    primarykey
    data
    text
    <p>This question arose from the following question :</p> <p><a href="https://stackoverflow.com/questions/18804955/chaining-methods-of-atl-com-objects">Chaining methods of ATL/COM objects</a></p> <p>Let's say I have a instance <code>MyObj1</code> of an ATL/COM class <code>TheClass</code> of a dll exposed to vba, and a method <code>TheMethod</code> of <code>TheClass</code>.</p> <p>In VBA, I have a function</p> <pre><code>Public Function func(x as Variant) as Variant '... something MyObj1.TheMethod( x ) '... other things End Function </code></pre> <p>This function is used in excel, and I pass an excel range of cell to it. At debug in VBA, x is seen of vba type "<code>Variant/Object/Range</code>", and has a "<code>Value2</code>" of vba type "<code>Variant/Variant</code>", and if the range is for instance a rectangle containing expty cells and doubles in excel, when <code>Value2</code> is unfolded (still in watch in debug in vba), it is composed of <code>Variant</code>'s of types "<code>Variant/Double</code>" or "<code>Variant/Empty</code>". It is this "core" "<code>Value2</code>" <code>Variant</code> that I would like to isolate in the next step, <strong>in c++</strong>.</p> <p>At the next step, at debug in c++ at the entry of the ATL method <code>TheMethod</code> of signature</p> <pre><code>STDMETHODIMP TheClass::TheMethod( VARIANT* var_in ) </code></pre> <p><code>var_in</code> (which received the latter <code>x</code>) is seen having a <code>vt</code> equal to <code>VT_DISPATCH</code>. This guy carries for sure (even if I don't know) all the stuff already carried by the latter <code>x</code>, but I would like to know how to isolate the "<code>Value2</code>" part of it to catch it and work with it, as only the <code>Value2</code> part interests me.</p> <p>Let me say that I know that rather than doing it in c++, I could do this in vba :</p> <pre><code>Public Function func(x as Variant) as Variant '... something MyObj1.TheMethod( x.Value2 ) '... other things End Function </code></pre> <p>but <strong>I don't want to resort to such thing in VBA</strong>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload