以编程方式重新加载Excel加载项

以编程方式重新加载Excel加载项

本文介绍了以编程方式重新加载Excel加载项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有许多功能的excel插件.我在功能区上有一个名为配置设置"的按钮,该按钮允许用户选择是否允许某些选项(是否包括右键单击菜单或在我的功能区上显示一些按钮).

I have an excel plug in that has a number of features. I have a button on the ribbon titled "configuration settings" that allows the user to select whether or not to allow some options (whether to include a right click menu, or to display some buttons on my ribbon).

我知道的定义右键菜单或设计功能区的唯一方法是在excel插件的启动中.

The only way that I know to define a right click menu or to design the ribbon is in the start up of the excel addin.

我有一个配置文件,该文件会在加载时进行检查,但是如果用户使用我的功能区按钮更改配置,则在重新打开excel或用户手动重新加载插件之前,该配置文件无效.有没有办法通过编程方式做到这一点?

I have a config file that gets checked on load, but should the user change the configuration using my ribbon button, it has no effect until excel is re-opened or the user manually reloads the addin. Is there a way to do this programmatically?

推荐答案

可能您可以有两个插件. (Addin1,Addin2)​​

Probably you could have two addins. (Addin1, Addin2)

第一个没有任何功能区但读取配置的插件(Addin1),然后启用另一个插件(Addin2)​​.

First addin (Addin1) which doesnt have any ribbons but reads the configuration and then enables another addin (Addin2).

要启用外接程序,请使用以下代码.

To enable the addins use the following piece of code.

foreach (COMAddIn addin in Application.COMAddIns)
{
   if (addin.ProgId.ToLower().Contains("addin2") && addin.Connect != true)
   {
      addin.Connect = true;
   }
}

这篇关于以编程方式重新加载Excel加载项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:57