none
On-the-fly Ribbon without VSTO? RRS feed

  • Question

  • I have a customer moving (not soon enough) from Word 2003 to 2010.  They would like an add-in that is compatible with both versions of Word, and would greatly prefer not having to do a DLL install on each user's computer -- that makes a "global template" the optimal solution.

    A .dotm won't run in 2003, but they'd very much like to have a custom tab on the Ribbon with the custom features I'm adding -- without having to use the AddIns tab.

    I know this can be accomplished with a VSTO project, but that creates a DLL that must be installed.  Can the IRibbonUI interface, specifically the OnLoad functionality, be accomplished solely within a .dot?

    Everything beyond that I can handle: a little late binding... some Application.Version checks... and the 2003 versus 2007 differences are trivial.  I just can't get at the IRibbonUI object, so far as I can tell, without creating a VSTO add-in.

    Thanks in advance,

    Joel

    Wednesday, January 18, 2012 10:39 PM

All replies

  • Hi Joel

    About the only thing I can imagine would be a multi-part add-in with three templates. One *.dot template that's in the StartUp folder and is loaded automatically. The main or only purpose of this would be to load the add-in template that's appropriate for the version of Word that loads. So it does an Application.Version check, then loads the *.dot with toolbars or the *.dotm with the Ribbon (both of which must be saved somewhere other than the Startup folder).

    The trickiest part about this will be the actual VBA code. Best would certainly be to have the code in each template and not try to share it. Maintenance will be more difficult, but in any case, the macros that link to the UI (assigned to the CommandBars or the Ribbon) will have to be different. What could work would be yet another template that holds the "shared code"...

    Note: RibbonXML can be saved inside an Office file (as alternative to VSTO). Look for the Custom UI Editor, a free download, to add the Ribbon XML to an Office file.


    Cindy Meister, VSTO/Word MVP
    Thursday, January 19, 2012 7:14 AM
    Moderator
  • Cindy,

    Thanks, I am already aware of those solutions -- I've seen examples of the "front end loader" where a .dot  loads up a .dotm with the GUI, and I've built RibbonXML for a commercial product in a .dotm.

    I have really been hoping for some trick that let a .dot file do the sort of things that otherwise require the OnLoad routine that a VSTO add-in can provide (the RibbonUI object).

    Your suggestions have the disadvantage that more than one file must be installed, which leads to user confusion.

    Joel

    Thursday, January 19, 2012 2:19 PM
  • Hi Joel

    As far as I know, there's nothing else. Since the binary *.doc file format is involved, there's no option to use Open XML to load the customizations you need on-the-fly, before the file is opened.

    The VSTO approach works because the Ribbon XML is not saved in the file, but brought in via the VSTO DLL. There's no way you can do this with a single Word file.


    Cindy Meister, VSTO/Word MVP
    Thursday, January 19, 2012 3:40 PM
    Moderator
  • Cindy,

    Thanks again for the clarification.  I of course understood that the Open XML approach wouldn't work (although I fail to comprehend why Word 2003 can read .docx files but not .dotm's -- which would solve my problems simply -- I'd just hide the 2003-style toolbar when Application.Version is 2007 [12] or above), but some sort of API call that could return the RibbonUI object would greatly simplify things. 

    I'm guessing it's not there so that the sorts of toolbar nightmares that appeared in 2003 and before can't continue (I can give you reams of evidence that a particular software vendor didn't play nice in their pre-2007 add-ins), but to relegate it only to the VSTO add-ins seems limiting.

    Joel

    Thursday, January 19, 2012 4:46 PM