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 di开发者_高级运维sabled 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
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.
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 );
}
I suspect that the problem relies in normal.dot template. Try to save normal template after removing buttons, commandbars etc using:
wordApplication.NormalTemplate.Save();
精彩评论