Managed Code Extension and Active Document Container

I have a Word document with managed code extensions that I am trying to use with an Active Document Container application written using MFC.

The Word document has a bookmark event handler written in C# using VSTO, and an embedded Windows Forms calendar control. If I open the document using Word, I can see the calendar control and I can see the result of my event handler by double-clicking on the bookmark.

However, if I run my ADC application, choose Edit-->Insert New Object, select Create from File, and navigate to my Word document, the document is inserted, but the bookmark event handler is not called when I double click, and the calendar appears briefly and then disappears.

It looks like the VSTO extension is loaded but then for some reason is discarded or disabled.

Any ideas

Any help would be very welcome.



Answer this question

Managed Code Extension and Active Document Container

  • ButlerDJ

    Maarten,

    Thank you for your response.

    Yes, your interpretation is correct. The Word document is being embedded in an MFC window.

    Because the MFC window is an Active Document Container (ADC), the document does not appear as a typical OLE embedded object but instead the embedded document takes over the entire frame, and the menus and toolbars of the embedded objects parent application (in this case Word) are visible.

    But I'm pretty sure the ADC technology is really an extension of OLE embedded objects, so if VSTO customizations are not supported for embedded objects, they won't work for the ADC case either.

    Do you have any idea why it does not work Is there any possible workarounds I could try... or are there any diagnostic tools I could use to try to determine exactly what is happening

    Thanks again.


  • Lucianamaría


    Well in fact it IS still a Word document (notice it shows you the Word icon in Explorer )

    As I said, you take the word document, Save As xml.

    I had an application that did the embedding for me, but I tested it with a random 'container' application and noticed I had to fool them a bit by renaming the .xml back to .doc (remember, the file is in xml-wordml formatting).

    Example:

    Rename your file abc.xml to abc.doc
    Open MS Powerpoint
    Select Menu Insert Object
    Select abc.doc
    Save your project file

    Now when you doubleclick the object your doc is launched.

    Next thing would be doing the same thing with a document with customizations.

    -= Maarten =-



  • Mr. Bungle


    What I think you are telling is that you can't get the Word document to work from an 'embedded' situation. Correct me if I interpreted it wrong.

    To my knowledge, and I tried it myself, loading VSTO customizations in embedded case is not supported. It was considered but ... didn't make it in 2.0

    -= Maarten =-



  • music_at_ulan

    Maarten,

    This suggestion sounds interesting, but I'm not really sure what you mean. If I save the word document as XML, it is no longer a Word document and I cannot embed it in my MFC window using Insert-->Object.

    Can you elaborate on your suggestion, please


  • joshcsmith13

    Just want to confirm with you that the embeded scenario you are trying to implement is not supported in VSTO2. As far as I know, the loader does not load the customization if it's embeded.

    Jing Lou - SDET Lead


  • Anonymous2342323432

    Maarten,

    unfortunately this did not work in my situation. With an ADC, you don't have to double click to 'Activate' the embedded item - instead, once the Word document is inserted, it immediately becomes active.

    You can create a simple ADC in a few minutes if you want to see what I am describing:

    In VS 2005, select File->New Project
    Select MFC, then MFC Application, and enter a name for the project.

    In the MFC Application Wizard, choose the following:
    On the Application Type screen, Application type: Single Document, everything else leave as default.
    On the Compound Document Support screen, select Container, and Active Document Container.
    That's all, just click Finish, then build and run the project.


    When the app runs, select Edit->Insert New Object, Create from File, then click on any Word document. You'll see how the document takes up the entire frame.

    My problem is that if the inserted document contains any VSTO extensions, they are not loaded or are somehow disabled.


  • tcheck


    For what I heard it was just a matter of time, not enough resources, to make it in this version. Technically there are no issues.

    I can give you an option that worked for me. The thing I did is save the document as XML and stored this in my 'container' application. The assembly is stored somewhere else on the machine. It seemed that the customization was not shut down using the document in XML mode...

    Try it yourself, and let me know if this worked for you too.

    -= Maarten =-



  • Managed Code Extension and Active Document Container