【VSTO】エクセルを開いたとき、シートがアクティブになったときのイベント処理
VSTOをはじめて作ってみたので、それのメモ
環境
C#
イベント処理
ThisAddIn.cs
//(省略)
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WorkbookActivate += Application_Active;
this.Application.SheetActivate += Sheet_Active;
}
void Application_Active(Excel.Workbook wb)
{
//起動時の処理を書きます~
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
MessageBox.Show(activeWorksheet.Name, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void Sheet_Active(object sh)
{
//シートアクティブの処理を書きます~
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
MessageBox.Show(activeWorksheet.Name, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
ThisAddIn.cs
//(省略)
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WorkbookActivate += Application_Active;
this.Application.SheetActivate += Sheet_Active;
}
void Application_Active(Excel.Workbook wb)
{
//起動時の処理を書きます~
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
MessageBox.Show(activeWorksheet.Name, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void Sheet_Active(object sh)
{
//シートアクティブの処理を書きます~
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
MessageBox.Show(activeWorksheet.Name, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Author And Source
この問題について(【VSTO】エクセルを開いたとき、シートがアクティブになったときのイベント処理), 我々は、より多くの情報をここで見つけました https://qiita.com/naoto_koyama/items/7c7e434a465dc470b140著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .