Microsoft 开发人员网络 > 论坛主页 > Windows Presentation Foundation (WPF) > How to host word as a OLE/ActiveX control in WPF?
提出问题提出问题
 

已答复How to host word as a OLE/ActiveX control in WPF?

  • 2007年7月5日 6:13Larry_zhou 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    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.

     

    Walkthrough: Hosting an active Control in Windows Presentation Foundation

          ms-help://MS.MSSDK.1033/MS.NETFX30SDK.1033/wpf_conceptual/html/1931d292-0dd1-434f-963c-dcda7638d75a.htm

答案

  • 2007年7月5日 18:45Chango V. - MSFT 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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.

全部回复

  • 2007年7月5日 9:16Neal Hudson 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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


  • 2007年7月5日 18:45Chango V. - MSFT 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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.

  • 2007年7月6日 6:06Larry_zhou 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    Dear Chango,

      

        Thanks for your information. They are very useful for me.

    I'll learn and try.