Hi maa

I was thinking about what you said PS: and in part I think you were correct! It is not documented but I have found out by testing and finally by the author note that any "string variant -> Variant(VT_BSTR, '');" regardless if it is passed by reference "VT_BYREF" or not, can not be used if that "string variant" will be used in a method -> $object->Method(); because the $object->Method(); will assign the "variant" to a "string variant value"!

So in short, by doing this....

my $sugg = Variant(VT_BSTR|VT_BYREF, "");

I was assigning $sugg to an absolute value = "", that could not be changed by the method -> $object->Method(); that I was using it in...

The correct way to pass a "string variant" to a method -> $object->Method(); that will change or assign a value to the "string variant" is listed below...

my $sugg = Variant(VT_VARIANT|VT_BYREF, "");

Authors Note...
After the method call $sugg will hold the returned value for the $sugg variant. It will still be variant but the overloading converts it to string representation automatically.

A side note (to help others you might run into this problem)...

Any "OLE String -> VT_BSTR or OLE Boolean -> VT_BOOL" that are placed in a "object Method" and they will return a value by the "method" that they are placed in should be called "VT_VARIANT"

Thanks Mark

@dawn

In reply to Re: Re: Win32::OLE (Variants by reference) by @dawn
in thread Win32::OLE (Variants by reference) by @dawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.