Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include "./MSWord/msword8.h"
- // Define this according to the Outlook Object
- // Model version you are compiling under
- #define OUTL12 // Outlook 2007
- #pragma warning(disable:4146)
- #if defined(OUTL12) // Outlook 2007
- #import "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\mso.dll" \
- no_namespace
- #import "C:\Program Files\Microsoft Office\OFFICE12\msoutl.olb" \
- rename_namespace("Outlook")
- #endif // OUTL12
- #pragma warning(default:4146)
- void GetOutlookWordEditor (MSWord::_Application *pWordApp)
- {
- CLSID clsid;
- LPUNKNOWN pUnk;
- CLSIDFromProgID(L"Outlook.Application", &clsid);
- HRESULT hr = ::GetActiveObject(clsid, NULL, &pUnk);
- if (SUCCEEDED(hr))
- {
- // Get IDispatch
- IDispatch *pDispApp;
- HRESULT hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDispApp);
- if (FAILED(hr))
- {
- return;
- }
- pUnk->Release();
- Outlook::_ApplicationPtr outlookApp(pDispApp);
- if(outlookApp->ActiveInspector()!=NULL)
- {
- Outlook::_InspectorPtr pInsp(outlookApp->ActiveInspector());
- if(pInsp!=NULL)
- {
- IDispatch *pDispWordEditor;
- MSWord::_Document document;
- if (SUCCEEDED(pInsp->get_WordEditor(&pDispWordEditor)))
- {
- pDispWordEditor->QueryInterface(__uuidof(MSWord::_Document), (LPVOID *)&document);
- }
- }
- }
- }
- return;
- }