RemoveMe() Code in Excel 2000 not working

171 views
Skip to first unread message

andste

unread,
Sep 11, 2011, 7:44:36 PM9/11/11
to Excel-DNA
Hi forum,

I just noticed that the code below does not work in Excel 2000
(9.0.6926 SP-3). The operating system is Windows XP SP-3 with .NET
framework 3.5. The code works fine in Office 2007 and more recent
version.

"Not working" means that the functions are not unregistered.

With regards,
Andi


Public Shared Sub RemoveMe()
'
Dim myName As String = DirectCast(XlCall.Excel(XlCall.xlGetName),
String)
Dim removeId As Object = XlCall.Excel(XlCall.xlfRegister, myName,
"xlAutoRemove", "I", ExcelMissing.Value, ExcelMissing.Value, 2)
Dim removeResult As Object = XlCall.Excel(XlCall.xlfCall, removeId)
Dim removeUnregister As Object = XlCall.Excel(XlCall.xlfUnregister,
removeId)
End Sub

Govert van Drimmelen

unread,
Sep 12, 2011, 3:45:02 AM9/12/11
to Excel-DNA
Hi Andreas,

I don't have an Excel 200 close to test, but will try on my Excel 2002
later in the week.

For now, maybe you can try the C# code from this previous thread,
checking the issues that we sorted out there - maybe it is just an
Excel-DNA version issue, or how you are running from AutoOpen, or
something.

-Govert

andste

unread,
Sep 12, 2011, 7:18:33 AM9/12/11
to Excel-DNA
> For now, maybe you can try the C# code from this previous thread,
> checking the issues that we sorted out there - maybe it is just an
> Excel-DNA version issue, or how you are running from AutoOpen, or
> something.
We discussed the code that I am using in the thread "Unregistering Not
Working Anymore Optionen".
The fact that this code is not working in Excel 2000 and 2002 means
that the workaround
you have proposed in that thread does not work with all Excel
versions. I might be worth checking that
the fix you mentioned for a 0.30 version (the an_opened flag) works
with Excel 2002.

In the meantime, workarounds for Excel 2002 are most welcome... :-)

Rgrds,
Andi

andste

unread,
Sep 12, 2011, 6:22:33 AM9/12/11
to Excel-DNA
Thank you in advance. I encounter the same issue on Office XP (i.e.
Excel 2002). Rgrds, Andi
> > End Sub- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Govert van Drimmelen

unread,
Sep 13, 2011, 5:16:54 PM9/13/11
to Excel-DNA
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>

andste

unread,
Sep 16, 2011, 4:18:19 AM9/16/11
to Excel-DNA
Hi Govert,
Thank you very much for your investigations. It works: I set up a test
machine running Windows XP SP-3 running various Excel version: Excel
95, Excel 97, Excel 2000 and Excel XP. And I can confirm that the
RemoveMe() functions works in all of these environemts, and also on my
productive environment which is Win 7 64-Bit / Office 2010 64-bit.

Let me know if you need to do some additional. I will try to keep
alive my test machine as long as possible.

Rgrds,
Andi

Govert van Drimmelen

unread,
Sep 16, 2011, 4:36:28 AM9/16/11
to Excel-DNA
Hi Andi,

Surely not Excel 95 !?

-Govert

andste

unread,
Sep 16, 2011, 10:45:45 AM9/16/11
to Excel-DNA
Microsoft Excel for Windows 95
Version 7
Copyright 1985-1995 Microsoft Corporation

I almost had tears in my eyes when I saw that ugly logo again...

The functionality I am using does not depend on Excel in any way. I am
just using ExcelDNA to wire a .NET dll to Excel.

Why are you surprised about Excel 95?

Rgrds,
Andi

Govert van Drimmelen

unread,
Sep 17, 2011, 5:21:12 AM9/17/11
to Excel-DNA
Wow Andi!

I was under the impression that the .xll API had changed a lot between
Excel in Office '95 and Excel '97, so that the Excel-DNA .xll would
not be compatible.
That means we can expect Excel-DNA add-ins to work under Windows 98
(the oldest version that supports .NET 2.0) with Excel '95.

Anyway, I'd suggest your Excel '97 users install the Office SP-2,
apparently there were some serious bugfixes for the C API.

Have you any idea what percentage of your users are running Excel 2000
or older?
I'm planning to implement async support next year, using RTD for
versions before Excel 2010. But RTD was only added in Excel 2002... so
I'd like to know if this is likely to be an issue.

Regards,
Govert

andste

unread,
Sep 18, 2011, 1:47:16 PM9/18/11
to Excel-DNA
I have no idea about the distribution of Excel versions in circulation
(would be very interesting to know that).
There is definitily a large group of users running versions just below
Excel 2007 for performance reasons; many of them
still seem to sit on Win XP. Related to my acitivities, I do come
across users working with very ancient Excel. These users
typically use non-English language version (Japanese, German, ...). My
interpretation is that they are stuck with
productive language-specific VBA applications that would require
significant changes on newer Excel versions.

Besides Excel, there is also a version issue on the .NET side: your
latest resizer functionality for example requires .NET 4.0,
while most other code runs fine on .NET 3.5. Several .NET versions
together with several Excel versions and several Windows
versions result in a rather impressive number of possible system
configurations.

Rgrds,
Andi

Govert van Drimmelen

unread,
Sep 18, 2011, 2:36:17 PM9/18/11
to Excel-DNA
Hi Andi,

I think you're right that there are few Excel's older than Excel 2002,
but quite a lot still on Excel 2003.

I'm not sure (or have forgotten) why you say the resizer sample
depends on .NET 4.0. It shouldn't.

The only aspect of Excel-DNA that depends on .NET 4.0 is the Excel 64-
bit support. That could be fixed, but it would be a fair amount of
work.

Regards,
Govert

andste

unread,
Sep 22, 2011, 5:01:28 AM9/22/11
to Excel-DNA
> I'm not sure (or have forgotten) why you say the resizer sample
> depends on .NET 4.0. It shouldn't.
Resizer only works if I force runtime=v4 in the DNA file.

Govert van Drimmelen

unread,
Sep 22, 2011, 9:52:37 AM9/22/11
to Excel-DNA
Hi Andi,

I think my first version of the ArrayResizer didn't work on Excel 2003
with early versions of Excel-DNA 0.29.
But with the current version of Excel-DNA (0.29.12) it should work
fine under .NET 2.0 under all Excel versions.

If not you can start a new thread with your function and a description
of the problem.

-Govert
Reply all
Reply to author
Forward
0 new messages