SAFEARRAY [out] type

M

MB Blackburn

I have a question about VBA code in Excel. It is talking to an ActiveX
component.
Several methods in the component have method signatures that contain [in]
and [out] parameters of type SAFEARRAY.
More precisely the idl code reads:
[in] SAFEARRAY (float)* for the input and
[out, retval] SAFEARRAY (float)* for the output.

When I call a method with the [in] SAFEARRAY param, life is good...no
errors.
However, when I try to call a method with the [out, retval] SAFEARRAY param,
the methods fails with message: Unsupported automation type.
To get the method to work I have to change the idl code to read: [out,
retval] VARIANT *

The question: why is the SAFEARRAY recognized as a legit type for [in]
params but not [out] params?

m blackburn
 
C

Cindy M -WordMVP-

Hi MB,

Since no one else has answered, I'll venture it.

OFfice VBA doesn't recognize the type SafeArray; as far as it concerned, it
doesn't exist. Your ActiveX component does recognize it, so sending
information to a parameter of this typein the component is no problem (I
assume some kind of implicit casting is going on, done by the component). But
since Office VBA doesn't recognize it, you can't send data out using this
type. You have to do an explicit cast (Variant).
I have a question about VBA code in Excel. It is talking to an ActiveX
component.
Several methods in the component have method signatures that contain [in]
and [out] parameters of type SAFEARRAY.
More precisely the idl code reads:
[in] SAFEARRAY (float)* for the input and
[out, retval] SAFEARRAY (float)* for the output.

When I call a method with the [in] SAFEARRAY param, life is good...no
errors.
However, when I try to call a method with the [out, retval] SAFEARRAY param,
the methods fails with message: Unsupported automation type.
To get the method to work I have to change the idl code to read: [out,
retval] VARIANT *

The question: why is the SAFEARRAY recognized as a legit type for [in]
params but not [out] params?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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