How to embed a MS Word in a window
-
Hi in my project there is a window where I have to embed a word application using OLE. It is fine for Internet explorer, but for Word rather embedding it is opening as a separate application. One thing if I use IWebBrowser2 to achieve it is fine, but there is a problem relating to history so I am trying to do it in this way. The flow is as follows: The syntax is based on plain C. CLSID idMsWord; HRESULT hr; IStorage *pStorage; IOleObject *browserObject; _IOleClientSiteEx *_iOleClientSiteEx; hr = CLSIDFromProgID(L"word.document", &idMsWord); hr = StgCreateStorageEx(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE, STGFMT_DOCFILE, 0, NULL, 0, &IID_IStorage, (LPVOID*) &pStorage); if (!OleCreate(&idMsWord, &IID_IOleObject, OLERENDER_DRAW, 0, (IOleClientSite *)_iOleClientSiteEx, (void**)pStorage, (void**)&browserObject)) { GetClientRect(hwnd, &rect); rect = *R; // Let word object know that it is embedded in an OLE container. if (!OleSetContainedObject((struct IUnknown *)browserObject, TRUE)) { browserObject->lpVtbl->DoVerb(browserObject, OLEIVERB_INPLACEACTIVATE, NULL, (IOleClientSite *)_iOleClientSiteEx, -1, hwnd, &rect); browserObject->lpVtbl->Release(browserObject); } } _IOleClientSiteEx is the structure which holds IOleClientsite. Now when DoVerb is beieng executed a new word application is being opened as a separate application rather as an embedded one. Please help to resolve this issue as it is related to my project.
-
Hi in my project there is a window where I have to embed a word application using OLE. It is fine for Internet explorer, but for Word rather embedding it is opening as a separate application. One thing if I use IWebBrowser2 to achieve it is fine, but there is a problem relating to history so I am trying to do it in this way. The flow is as follows: The syntax is based on plain C. CLSID idMsWord; HRESULT hr; IStorage *pStorage; IOleObject *browserObject; _IOleClientSiteEx *_iOleClientSiteEx; hr = CLSIDFromProgID(L"word.document", &idMsWord); hr = StgCreateStorageEx(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE, STGFMT_DOCFILE, 0, NULL, 0, &IID_IStorage, (LPVOID*) &pStorage); if (!OleCreate(&idMsWord, &IID_IOleObject, OLERENDER_DRAW, 0, (IOleClientSite *)_iOleClientSiteEx, (void**)pStorage, (void**)&browserObject)) { GetClientRect(hwnd, &rect); rect = *R; // Let word object know that it is embedded in an OLE container. if (!OleSetContainedObject((struct IUnknown *)browserObject, TRUE)) { browserObject->lpVtbl->DoVerb(browserObject, OLEIVERB_INPLACEACTIVATE, NULL, (IOleClientSite *)_iOleClientSiteEx, -1, hwnd, &rect); browserObject->lpVtbl->Release(browserObject); } } _IOleClientSiteEx is the structure which holds IOleClientsite. Now when DoVerb is beieng executed a new word application is being opened as a separate application rather as an embedded one. Please help to resolve this issue as it is related to my project.
Here is an example, if that might help: Using MS Office in an MFC application[^]
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Here is an example, if that might help: Using MS Office in an MFC application[^]
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Thanks As you look at my code there is no use of MFC class. So I have to achieve this without MFC class.
-
Thanks As you look at my code there is no use of MFC class. So I have to achieve this without MFC class.
Yajnesh Naraya Behera wrote:
So I have to achieve this without MFC class.
That must be a real pain. Good luck. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Yajnesh Naraya Behera wrote:
So I have to achieve this without MFC class.
That must be a real pain. Good luck. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Yap it is really. Now I got some concept, I have to implement an OLECONTAINER to host MS Word, again from where I will get the interfaces for Word. In other way I can use all the proeprties & methods of MS Word using IDispatch, but what about other interfaces IOleClientSite, IOleInPlaceFrame. All your sugestions valuable in this regard.
-
Yap it is really. Now I got some concept, I have to implement an OLECONTAINER to host MS Word, again from where I will get the interfaces for Word. In other way I can use all the proeprties & methods of MS Word using IDispatch, but what about other interfaces IOleClientSite, IOleInPlaceFrame. All your sugestions valuable in this regard.
This thread is pretty much buried now. You may want to start a new thread, explaining your problem. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP