Hi Andreas,
It looks like I found the problem. It seems Excel 2002 (and presumably
Excel 2000) is more sensitive to the parameters passed to xlfRegister
(in the RemoveMe macro).
I've just changed two of the arguments from ExcelMissing.Value to
ExcelEmpty.Value, and now it works on both my Excel 2007 and Excel
2002. I paste the complete .dna file below for future reference.
Let us know if you still have a problem.
Regards,
Govert
<DnaLibrary Language="CS">
<Reference Name="System.Windows.Forms"/>
<![CDATA[
using System;
using System.Windows.Forms;
using ExcelDna.Integration;
public class Test : IExcelAddIn
{
public void AutoOpen()
{
DialogResult result =
MessageBox.Show("Should the Add-In be loaded?",
"Add-in check", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
{
double now = (double)XlCall.Excel(XlCall.xlfNow);
XlCall.Excel(XlCall.xlcOnTime, now, "RemoveMe");
}
}
public void AutoClose()
{
}
public static void RemoveMe()
{
string myName = (string)XlCall.Excel(XlCall.xlGetName);
object removeId = XlCall.Excel(XlCall.xlfRegister, myName,
"xlAutoRemove", "I" , ExcelEmpty.Value,
ExcelEmpty.Value, 2);
object removeResult = XlCall.Excel(XlCall.xlfCall, removeId);
object removeUnregister = XlCall.Excel(XlCall.xlfUnregister,
removeId);
MessageBox.Show("This add-in has been disabled.", "Add-in
check");
}
public static string TestFunction()
{
return "Hello! I'm here...";
}
}
]]>
</DnaLibrary>