Problem with Variant

Hi All,

I am trying to automate Word in VC++. One of its API expects me to pass a Variant pointer of a structure (defined by Word itself).

Following snippet gives me some problem with GetRecordInfoFromTypeInfo. The function returning error code of "Invalid argument/arguments"

ITypeInfoPtr *pTI = new ITypeInfoPtr;
HRESULT hr = rng->GetTypeInfo( 0, LOCALE_SYSTEM_DEFAULT, &(*pTI) );
if( hr == S_OK )
{
IRecordInfoPtr *pRI = new IRecordInfoPtr;
hr = GetRecordInfoFromTypeInfo( *pTI, &(*pRI) );
if( hr == S_OK )
{
VariantInit( &anchor );
anchor.vt = VT_RECORD;
anchor.pvRecord = rng;
anchor.pRecInfo = *pRI;
pRI = NULL;
Word::CanvasShapesPtr csptr = document->Shapes->AddCanvas( 10, 10, 20, 20 ,&anchor );

document->Shapes->AddShape( Office::msoShapeOval, 10, 10, 20, 20 )->Fill->ForeColor->RGB = RGB( 0,0,0+col*50 );
celTable->Shading->BackgroundPatternColor = ( enum Word::WdColor )RGB( 0+col*50, 0, 0+col*50 );

}
else
{
cout<<"Problem \n";
}
delete pRI;
}

delete pTI;

Thanks in advance. All help would be welcome :-)

Prasad
[1362 byte] By [prasad_godde] at [2007-11-19 18:27:29]