0
我正在测试Excel-Dna并希望在Excel中运行一些简单代码的按钮。我的理解它下面的代码应在加载项选项卡在Excel中添加一个按钮:自定义菜单命令不显示在Excel的加载项选项卡上
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExcelDna.Integration.CustomUI;
using NetOffice;
using NetOffice.ExcelApi;
using ExcelDna.Integration;
using ExcelPluginTest;
namespace ExcelPluginTest
{
public class AddIn : IExcelAddIn
{
public static Application Excel { get; set; }
public void AutoOpen()
{
Factory.Initialize();
Excel = new Application(null, ExcelDnaUtil.Application);
}
public void AutoClose()
{
}
}
public class ExcelHelper
{
public static Application Excel { get { return AddIn.Excel; } }
[ExcelCommand(MenuName = "ExcelPlugin Test", MenuText = "Write the Excel version")]
public void WriteTheVersion()
{
var ver = Excel.Version;
var rng = Excel.Range("B3");
rng.Value = ver;
}
}
}
但是外接程序选项卡不可见,甚至,即使它在文件的检查|选项|自定义功能区。我不确定是否发生这种情况,因为没有任何可显示的东西(在我的代码中存在问题),或者该按钮实际上存在,但我无法看到它,因为加载项选项卡已隐藏(我确认AddIn已加载(在AutoOpen中设置BP))。
完美Govert,感谢您的快速回复! – Remko