MSDN > Home page del forum > Windows Presentation Foundation (WPF) > How to host word as a OLE/ActiveX control in WPF?
Formula una domandaFormula una domanda
 

Con rispostaHow to host word as a OLE/ActiveX control in WPF?

  • giovedì 5 luglio 2007 6.13Larry_zhou Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    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

Risposte

  • giovedì 5 luglio 2007 18.45Chango V. - MSFT Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta

    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.

Tutte le risposte

  • giovedì 5 luglio 2007 9.16Neal Hudson Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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


  • giovedì 5 luglio 2007 18.45Chango V. - MSFT Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta

    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.

  • venerdì 6 luglio 2007 6.06Larry_zhou Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    Dear Chango,

      

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

    I'll learn and try.