How to generate a cell click event in Excel 2007 VSTO with VB?
Well I have browsed through Application events in Excel 2007 howe开发者_JAVA百科ver I can't find any event generated on a cell click.
I can't use a double click event at the moment due to application constraints. Is there a way I can create a custom click event and attach it to a sheet for generating a cell click event.You should be able to capture that through the Worksheet.SelectionChange event, as illustrated in the snippet below. If you are interested in single cells, you may have to make sure that the range is a single cell.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
var sheet = this.Application.ActiveSheet as Excel.Worksheet;
sheet.SelectionChange += new Excel.DocEvents_SelectionChangeEventHandler(sheet_SelectionChange);
}
void sheet_SelectionChange(Excel.Range Target)
{
MessageBox.Show("Changed!");
}
精彩评论