0

I have two different COM add-ins, one for Word 2003 and one for Word 2007.

Word 2003 works like a charm every time, no issues etc...but now, when I open Word 2007, the buttons from Word 2003 appear in my Word 2007 ribbon. This still happens even after I disabled my add-in or clean my project...I've tried everything, including deleting all .dlls for my Word 2003 add-in but the problem still persists...

Any suggestions on what the problem is?

cheers

eglease
  • 2,445
  • 11
  • 18
  • 28
kUr4m4
  • 659
  • 2
  • 10
  • 24

3 Answers3

1

If you make a point of configuring those buttons in a template OTHER than normal.dot, they will automatically "go away" when you install.

It's generally considered bad practice to make changes to Normal.dot, but many people don't realize that unless you set the "CustomizationContext" property in word before creating you're own buttons and toolbars, that's precisely what you're doing, modifying normal.dot, and those changes WILL persist after you've uninstalled your addin.

DarinH
  • 4,868
  • 2
  • 22
  • 32
  • does this apply to COM add ins as well? – kUr4m4 Mar 28 '11 at 17:42
  • also, how can I solve the problem if it is indeed in normal.dot? I looked at it on the word options and I doesn't show any particular add in in there... :/ – kUr4m4 Mar 28 '11 at 17:47
  • The addin won't be in normal.dot, but if you open the file in a hex editor, and browse through it, you should see the menu and toolbar definitions, names etc. Only way to remove it is using danbystroms's code here or just delete the normal.dot and let word regenerate it (which is what I usually do, and what a lot of clients do, so I've always tried really hard NOT to rely on mods to Normal.dot because of that. – DarinH Mar 29 '11 at 14:12
  • About COM vs .net addins. At the end of the day, a .net VSTO addin is just a .net wrapper around the com IExtensibility stuff. they're basically the same beast under the covers, so yes, it'd apply to bare COM addins as well. – DarinH Mar 29 '11 at 14:13
  • I don't follow your answer. How do you configure the buttons for a different template? And where/how do you set the CustomizationContext? – Keith Jul 27 '11 at 16:09
0

You must "manually" remove the button as part of your uninstall process. This is the code I use:

    public static void removeWordToolbarButton(
        Microsoft.Office.Interop.Word.Application word )
    {
        var commandBar = word.CommandBars["Tools"];
        var btn = commandBar.FindControl(
            Microsoft.Office.Core.MsoControlType.msoControlButton,
            System.Reflection.Missing.Value,
            "name_of_the_button",
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value ) as Microsoft.Office.Core.CommandBarButton;
        if ( btn != null )
        {
            btn.Delete( -1 );
            Marshal.ReleaseComObject( btn );
        }
        Marshal.ReleaseComObject( commandBar );
    }
Dan Byström
  • 9,067
  • 5
  • 38
  • 68
  • thanks a lot danbystrom! That helps because I actually have toolbar buttons to remove but I also have a menubar button that gets put into my ribbon, that code should work for it as well right? – kUr4m4 Mar 28 '11 at 01:10
  • Where should this code be invoked? From the ribbon? An Installer class? – Keith Jul 27 '11 at 16:10
0

I suspect that the problem relies in normal.dot template. Try to save normal template after removing buttons, commandbars etc using:

wordApplication.NormalTemplate.Save();
sfradel
  • 61
  • 2