Skip to content

Instantly share code, notes, and snippets.

@fantasticswallow
Created October 3, 2015 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fantasticswallow/efc36f270b219d9573ad to your computer and use it in GitHub Desktop.
Save fantasticswallow/efc36f270b219d9573ad to your computer and use it in GitHub Desktop.
hogehoge
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
namespace ExcelAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Application.SheetActivate += Application_SheetActivate;
}
private void Application_SheetActivate(object Sh)
{
var sh = (Excel.Worksheet)Sh;
InternalOperator.EventCollection.Add(string.Format("Sheet Activate : {0}", sh.Name));
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
internal static void GoNextSheet(bool isBack = false)
{
var wb = Globals.ThisAddIn.Application.ActiveWorkbook;
var index = ((Excel.Worksheet)wb.ActiveSheet).Index;
if (isBack)
{
index -= 1;
if (index < 1)
{
index = wb.Sheets.Count;
}
}
else
{
index += 1;
if (index > wb.Sheets.Count)
{
index = 1;
}
}
var sh = (Excel.Worksheet)wb.Sheets.Item[index];
sh.Activate();
}
#region VSTO で生成されたコード
/// <summary>
/// デザイナーのサポートに必要なメソッドです。
/// このメソッドの内容をコード エディターで変更しないでください。
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment