Created
July 13, 2011 09:18
-
-
Save crazyfool2100/1079974 to your computer and use it in GitHub Desktop.
This add-in causes problems with embedded Excel sheets in Microsoft Word documents.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DnaLibrary RuntimeVersion="v4.0" Language="C#"> | |
<Reference Name="System.Windows.Forms" /> | |
<Reference Name="Microsoft.Office.Interop.Excel" /> | |
<![CDATA[ | |
using System; | |
using System.Reflection; | |
using System.Windows.Forms; | |
using ExcelDna.Integration; | |
using ExcelDna.Integration.CustomUI; | |
using ExcelDna.Integration.Extensibility; | |
using Microsoft.Office.Interop.Excel; | |
public class AddIn : IExcelAddIn | |
{ | |
private Microsoft.Office.Interop.Excel.Application app; | |
public AddIn() | |
{ | |
} | |
public void AutoOpen() | |
{ | |
app = (Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application; | |
app.SheetActivate += new AppEvents_SheetActivateEventHandler(EventHandler_SheetActivate); | |
app.WorkbookActivate += new AppEvents_WorkbookActivateEventHandler(EventHandler_WorkbookActivate); | |
app.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(EventHandler_WorkbookBeforeClose); | |
app.SheetChange += new AppEvents_SheetChangeEventHandler(EventHandler_SheetChange); | |
app.WorkbookOpen += new AppEvents_WorkbookOpenEventHandler(EventHandler_WorkbookOpen); | |
app.SheetSelectionChange += new AppEvents_SheetSelectionChangeEventHandler(EventHandler_SheetSelectionChange); | |
} | |
public void AutoClose() | |
{ | |
} | |
private void EventHandler_WorkbookActivate(object obj) | |
{ | |
Workbook oBook = (Workbook)obj; | |
MessageBox.Show("Workbook Activate: " + oBook.Name); | |
} | |
private void EventHandler_SheetActivate(object obj) | |
{ | |
Worksheet oSheet = (Worksheet)obj; | |
MessageBox.Show("Sheet Activate: " + oSheet.Name); | |
} | |
private void EventHandler_WorkbookBeforeClose(Workbook oBook, ref bool Cancel) | |
{ | |
MessageBox.Show("Workbook Before Close: " + oBook.Name); | |
} | |
private void EventHandler_SheetChange(object obj, Range Target) | |
{ | |
Worksheet oSheet = (Worksheet)obj; | |
MessageBox.Show("Sheet Change: " + oSheet.Name); | |
} | |
private void EventHandler_WorkbookOpen(Workbook oBook) | |
{ | |
MessageBox.Show("Workbook Open: " + oBook.Name); | |
} | |
private void EventHandler_SheetSelectionChange(object obj, Range Target) | |
{ | |
Worksheet oSheet = (Worksheet)obj; | |
MessageBox.Show("Sheet Selection Change: " + oSheet.Name); | |
} | |
} | |
]]> | |
</DnaLibrary> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment