Error on fetching object in OLEObject

S

syrhus

I had a Ax in a OLEObject which is stored in the xls file and when I tried to
get the Object of the OLEObject, Excel crashes.
Someone could help me?


CComPtr<IDispatch> pDisp;
hr = pSheets->get_Item(CComVariant(wksndx), &pDisp);
if ( FAILED(hr) || pDisp == NULL )
continue;
CComQIPtr<XLS::_Worksheet> pWorksheet = pDisp;
if ( pWorksheet == NULL )
continue;

CComPtr<XLS::OLEObjects> pOLEObjects;
hr = pWorksheet->raw_OLEObjects(vtMissing, NULL, (IDispatch**)&pOLEObjects);
if ( FAILED(hr) || pOLEObjects == NULL )
continue;

CComPtr<XLS::_OLEObject> pOLEObject;
long lOLEObjects = -1;
hr = pOLEObjects->get_Count(&lOLEObjects);

if ( FAILED(hr) || lOLEObjects < 1 )
continue;

for ( long nOO = 1; nOO <= lOLEObjects ; ++nOO )
{
CComPtr<IDispatch> pDisp;
pOLEObject = NULL;
hr = pOLEObjects->raw_Item(CComVariant(nOO), (IDispatch**)&pOLEObject);
if ( FAILED(hr) || pOLEObject == NULL )
continue;

hr = pOLEObject->get_Object(&pDisp); //BUGING HERE !!!!!!!!
if ( FAILED(hr) || pDisp == NULL )
continue;
 

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