MSDN > 論壇首頁 > 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日 上午 06: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日 下午 06: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日 上午 09: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日 下午 06: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日 上午 06:06Larry_zhou 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Dear Chango,

      

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

    I'll learn and try.