Page 1 of 1
How to convert a safeArray ?
Posted: 15 Jan 2018 16:57
by Tonton Luc
Hi,
When I recover the Range value in a Excel sheet Range("B6:E8") using comDispInterface::getProperty, I obtein a comDomains::safeArray variant.
How to convert it in string_list (or integer_list) ?
Re: How to convert a safeArray ?
Posted: 15 Jan 2018 22:29
by Thomas Linder Puls
There are classes:
safeArrayBstr and
safeArrayInteger. With constructors
newCopy that takes a
nativeSafeArray as argument. They will raise an exception if the type does not match.
On such an object, you can call
getBoundaries to obtain a description of the indices and their range.
And then you can obtain individual elements using
getValue (and set them using
setValue).
Notice that you are responsible for destroying the array:
Code: Select all
predicates
safeArrayDestroy : (comDomains::nativeSafeArray SafeArray).
% @short See SafeArrayDestroy in MSDN
% @end
predicates
safeArrayDestroyData : (comDomains::nativeSafeArray SafeArray).
% @short
% @short See SafeArrayDestroyData in MSDN
% @end
predicates
safeArrayDestroyDescriptor : (comDomains::nativeSafeArray SafeArray).
% @short See SafeArrayDestroyDescriptor in MSDN
% @end
I believe you have to use the first since you must destroy both the descriptor and the data.
Re: How to convert a safeArray ?
Posted: 16 Jan 2018 10:29
by Tonton Luc
Thanks for your help.
My code work fine now :
Code: Select all
% with Selection = "D4:F6"
Values == Selection:getProperty("Value"),
if Values = comDomains::safeArray(SA) then
Array = safeArrayVariant::newCopy(SA),
Nb_array = Array:getBoundaries(), % [boundary(2,1),boundary(2,1)]
Prem = Array:getValue([3,3]), % return cell F6 value
_R_sa_destroy = safeArray_native::safeArrayDestroy(SA)
end if,