刚接触VSTO,想写一个简单的Excel add-in,有问题,急求帮助~
要求是Excel某单元格输入完后做一个验证,要求用VSTO做add-in,可是我代码里的SheetChange事件总是报错。第一次写VSTO,请教~代码如下:
using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
namespace ExcelAddIn
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
#region VSTO generated code
this.Application = (Excel.Application)Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy.Wrap(typeof(Excel.Application), this.Application);
#endregion
//MessageBox.Show("Deploy successfully");
this.SheetChange += new Excel.AppEvents_SheetChangeEventHandler(ThisAddIn_SheetChange);
}
private void ThisAddIn_SheetChange(object Item, Excel.Range Range)
{
MessageBox.Show("Sheet Changed!");
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
编译时划红线的这句话报错,信息是:'ExcelAddIn.ThisAddIn' does not contain a definition for 'SheetChange'
可我看别人类似的代码是这么写的呀,不解~望高手指教 --------------------编程问答-------------------- this.Application.SheetChange +=
补充:.NET技术 , C#