我是 Excel 插件编程的新手。我在 C# 中为 Excel 2010 创建了一个 Excel 插件,它将在每张工作簿中创建按钮。
有人能告诉我这段代码有什么问题吗:
Excel.Worksheet activeWorksheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
Microsoft.Office.Tools.Excel.Worksheet vstoWorksheet = activeWorksheet.GetVstoObject(Globals.Factory);
Excel.Range selection = vstoWorksheet.Range[2, 2];
Microsoft.Office.Tools.Excel.Controls.Button button = new Microsoft.Office.Tools.Excel.Controls.Button();
button.Tag = vstoWorksheet.Controls.AddControl(button,selection, "Click"); button.Name = "Click";
button.BackColor = System.Drawing.Color.Cyan;
button.Text = "Click";