In a MS Word automating program, I want to get a ShapeRange from a Shapes object, which need a SafeArray parameter. I wrote the following code:
——————————————
COleSafeArray sa;
DWORD bounds=1;
sa.Create(VT_VARIANT,1,&bounds);
COleVariant v_ind((long)1,VT_I4);
long ind=0;
sa.PutElement(&ind,&v_ind);
//sa.Detach();
CShapes shapes(doc.GetShapes());
CShapeRange sr(shapes.Range(sa));
——————————————-
It just throws an exception saying that the parameter has an invalid value. If I Detach the array before passing it to the Range method, the array becomes empty. Another exception is thrown out saying that out of bound.
Anyone can tell me how can I get it right?
Thx