VSTO中的工作表复制事件

时间:2014-01-20 09:29:08

标签: c# excel vsto add-in

我正在尝试捕获在工作簿中创建现有工作表的副本时触发的事件。我的目的是检查工作簿中存在多少份工作表,从而限制副本数量。

1 个答案:

答案 0 :(得分:0)

没有Sheet的Add事件。您需要使用Application.SheetActivateWorkbook.SheetActivateWorksheet.Activate事件。这是一个C#示例

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    this.Application.SheetActivate +=
    new Excel.AppEvents_SheetActivateEventHandler(
    Application_SheetActivate);
}

void Application_SheetActivate(object Sh)
{
    // Your code here to check if the copy is a duplicate or not
}