Skip to content

Instantly share code, notes, and snippets.

@crazyfool2100
Created September 7, 2011 05:36
Show Gist options
  • Save crazyfool2100/1199848 to your computer and use it in GitHub Desktop.
Save crazyfool2100/1199848 to your computer and use it in GitHub Desktop.
A host ExcelDna add-in loading and unloading another add-in
<DnaLibrary Name="Sample Add-In" Language="CS" RuntimeVersion="v4.0">
<Reference AssemblyPath="System.Windows.Forms.dll"/>
<Reference Name="Microsoft.Office.Interop.Excel" />
<![CDATA[
using System;
using ExcelDna.Integration;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
public class MyAddIn : IExcelAddIn
{
public void AutoOpen()
{
Excel.Application XL = (Excel.Application)ExcelDnaUtil.Application;
XL.OnKey("^p", "Macro_Test");
MessageBox.Show("Add-In Loaded.", "Add-In AutoOpen");
}
public void AutoClose()
{
}
public static void Macro_Test()
{
MessageBox.Show("Macro Test", "Macro Test");
}
}
]]>
</DnaLibrary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment