我有两个不同的 COM 加载项,一个用于 Word 2003,一个用于 Word 2007。
Word 2003 每次都像魅力一样工作,没有问题等……但是现在,当我打开 Word 2007 时,Word 2003 中的按钮出现在我的 Word 2007 功能区中。即使在我禁用我的加载项或清理我的项目之后,这种情况仍然会发生...我已经尝试了所有方法,包括删除我的 Word 2003 加载项的所有 .dll,但问题仍然存在...
关于问题是什么的任何建议?
干杯
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.
作为卸载过程的一部分,您必须“手动”删除该按钮。这是我使用的代码:
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 );
}
我怀疑问题出在 normal.dot 模板中。尝试在删除按钮、命令栏等后保存普通模板,使用:
wordApplication.NormalTemplate.Save();