LoginSignup
0
0

More than 5 years have passed since last update.

【VSTO】エクセルを開いたとき、シートがアクティブになったときのイベント処理

Last updated at Posted at 2018-03-16

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);

        }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0