locked
How to load an Add-In dynamically RRS feed

  • Question

  • Hello,

    Word 2007, VSTO 3.0

    I am writing a Word Add-In that needs to perform a ribbon customization contextually following two modes:

    - Mode 1: The standard word ribbon is displayed, with some customized tabs.
    - Mode 2: No standard tabs are displayed (startFromScratch = true), only customized tabs are available.

    In fact, I want to implement a behavior somewhat similar as the editing of embedded Excel worksheets in a Word document: when you enter the worksheet editing mode, all the Word ribbon is replaced by another Ribbon (in this case Excel).

    I have read a lot of posts regarding the dynamic customization of the ribbon and I have not found a solution to do the above. Basically, the best that I have found out is to define a single ribbon customization, which would reference all the Word built-in tabs and configure their visibility dynamically. However, it is not really equivalent to startFromScratch = true since for example the Quick Access Toolbar is not reset.

    I am trying a second approach: design two separate addins, one that will work in "mode 1" and the other in "mode 2". What I am trying to figure out is how to load/unload the add-in in "mode 2" from the add-in in "mode 1". I know it is technically possible since this functionnality is available in the Word Options/Add Ins dialog, where you can dynamically enable/disable COM add-ins. I have tested my two add-ins approach and it works fine this way: I enable mode2 addIn and the ribbon is reset with startFromScratch = true. When I diable it, the ribbon is restored to mode1. 

    Now, through the OM ... I have tried the Application.AddIns collection, but it does not manage the COM/VSTO add-ins.

    Does anybody know of a way to programmatically load a VSTO add-in ?

    Any suggestion will ge greatly appreciated.

    Thaks a lot

    --
    Cyril
    Monday, May 11, 2009 2:50 PM

Answers

  • With regards to the second half of your post - to access the installed COM add-ins (VSTO add-ins are a special subset of COM add-ins), you need to use the Application.COMAddIns property. The Application.AddIns property just gives you access to the installed Excel add-ins (.xla files). 

    For more information about loading VSTO add-ins programmatically, see the thread Load VSTO Excel AddIn Programmatically. Andrew Whitechapel has a blog post here that goes into more detail about the semantics of loading add-ins programmatically.

    I hope this helps,
    McLean Schofield
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Cyril Mathey Tuesday, May 12, 2009 11:32 AM
    Monday, May 11, 2009 7:34 PM
    Answerer

All replies

  • With regards to the second half of your post - to access the installed COM add-ins (VSTO add-ins are a special subset of COM add-ins), you need to use the Application.COMAddIns property. The Application.AddIns property just gives you access to the installed Excel add-ins (.xla files). 

    For more information about loading VSTO add-ins programmatically, see the thread Load VSTO Excel AddIn Programmatically. Andrew Whitechapel has a blog post here that goes into more detail about the semantics of loading add-ins programmatically.

    I hope this helps,
    McLean Schofield
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Cyril Mathey Tuesday, May 12, 2009 11:32 AM
    Monday, May 11, 2009 7:34 PM
    Answerer
  • Dear McLean

    Silly me ! I swear I looked for a COMXXX class in the Word Object Model Reference section of the online help and didn't find it. But I should have looked more thoroughly. The COMAddIns property is indeed documented, and it works like a charm. I can load/unload addIns just like I need.

    This is a great help for me (and a very fast answer too !).

    Thanks a lot.

    Regards

    --
    Cyril
    Tuesday, May 12, 2009 11:32 AM