CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"CATIA.Application", &clsid);
CComPtr<IUnknown> pCatiaSession;
hr = GetActiveObject(clsid, NULL, &pCatiaSession);
CATIAApplication * pApp = NULL;
hr = pSession->QueryInterface(IID_CATIAApplication, (void**) &pApp);
CATIADocument * pDocument = NULL;
hr = pApp->get_ActiveDocument(pDocument);
// Get the CATDocument pointer from the CATIADocument pointer.
CATBaseUnknown * pJunk = pDocument->GetImpl();
pCATDocument = (CATDocument*)pJunk;
// Do something with the CATDocument pointer
CATDocumentServices::SaveAs(*pCATDocument, strFilePath);