Although i have not tested above scenario, problem seems to be in the out parameter as GetActiveObject does not directly return IDispatch interface rather you need to query it from the IUknown interface.
Please see below an excerpt from
Office Automation Using Visual C++[
^]
USES_CONVERSION;
CLSID clsid;
HRESULT hr = CLSIDFromProgID(A2OLE("Word.Application"), &clsid);
IUnknown *pUnk;
IDispatch *pDispatch;
hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk;
if (hr == S_OK) {
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDispatch );
ASSERT(!FAILED(hr));
iWordApp.AttachDispatch(pDispatch);
}
iWordDoc = iWordApp.get_Documents();
pUnk->Release();