How to host word as a OLE/ActiveX control in WPF?
Hello, everyone,
How to host word/Excel/ppt as a OLE/ActiveX control in WPF?
I found a sample about how to host a ActiveX control in WPF in MSDN. But it is for Media Player and not for office. And I can't find any useful information about the question. Who can help me?
Thanks for any advice.
ms-help://MS.MSSDK.1033/MS.NETFX30SDK.1033/wpf_conceptual/html/1931d292-0dd1-434f-963c-dcda7638d75a.htmWalkthrough: Hosting an active Control in Windows Presentation Foundation
Answers
Larry,
For Office documents, you need more than the setup for hosting ActiveX controls. Office applications can act as active document servers, which implement a superset of the standard ActiveX interfaces and correspondingly require more support from the host than for ActiveX controls.
This article discusses the hosting requirements and comes with a C|++ ActiveX control that implements some of the additional functionality and can be used in a standard ActiveX host: http://support.microsoft.com/kb/311765. You could bundle that control with your application and host it using WinForms as shown in the Walkthrough you pointed to.
The easiest way to host an Office document is to navigate the WinForms WebBrowser control to a document. The WebBrowser control wraps the native one, which provides the active document hosting infrastructure. One limitation of this approach is that you won't have have access to the automation API of the Office application server hosting the document.
To avoid dependence on WinForms in your WPF application, you can instead use a WPF Frame element. It's also capable of hosting the native Web Browser control (which in turn can host active documents like those of Office), but due to implementation limitations it cannot be navigated directly to a .doc or .xls file. Instead, you can use a dummy HTML wrapper that points an <iframe> to the Office document.
All Replies
- I know this is PDF and not Word, but the techniques used would be the same, hopefully it points you in the right direction:
http://blogs.msdn.com/mhendersblog/archive/2005/09/23/473065.aspx Larry,
For Office documents, you need more than the setup for hosting ActiveX controls. Office applications can act as active document servers, which implement a superset of the standard ActiveX interfaces and correspondingly require more support from the host than for ActiveX controls.
This article discusses the hosting requirements and comes with a C|++ ActiveX control that implements some of the additional functionality and can be used in a standard ActiveX host: http://support.microsoft.com/kb/311765. You could bundle that control with your application and host it using WinForms as shown in the Walkthrough you pointed to.
The easiest way to host an Office document is to navigate the WinForms WebBrowser control to a document. The WebBrowser control wraps the native one, which provides the active document hosting infrastructure. One limitation of this approach is that you won't have have access to the automation API of the Office application server hosting the document.
To avoid dependence on WinForms in your WPF application, you can instead use a WPF Frame element. It's also capable of hosting the native Web Browser control (which in turn can host active documents like those of Office), but due to implementation limitations it cannot be navigated directly to a .doc or .xls file. Instead, you can use a dummy HTML wrapper that points an <iframe> to the Office document.
Dear Chango,
Thanks for your information. They are very useful for me.
I'll learn and try.


