0

我有两个不同的 COM 加载项,一个用于 Word 2003,一个用于 Word 2007。

Word 2003 每次都像魅力一样工作,没有问题等……但是现在,当我打开 Word 2007 时,Word 2003 中的按钮出现在我的 Word 2007 功能区中。即使在我禁用我的加载项或清理我的项目之后,这种情况仍然会发生...我已经尝试了所有方法,包括删除我的 Word 2003 加载项的所有 .dll,但问题仍然存在...

关于问题是什么的任何建议?

干杯

4

3 回答 3

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.

于 2011-03-28T16:19:35.463 回答
0

作为卸载过程的一部分,您必须“手动”删除该按钮。这是我使用的代码:

    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 );
    }
于 2011-03-27T18:13:26.657 回答
0

我怀疑问题出在 normal.dot 模板中。尝试在删除按钮、命令栏等后保存普通模板,使用:

wordApplication.NormalTemplate.Save();
于 2011-09-04T15:54:13.780 回答