Parameters get different value from Excel 365

43 views
Skip to first unread message

Mike

unread,
Nov 7, 2022, 10:17:09 PM11/7/22
to Excel-DNA
I write a function like this
public static void Test(string str1).

On Excel 365, I call this function.

=Test(C1). 

Excel 2000 passes the Cell Name "$C$1" to the function.
Excel 365 passes the value of Cell $C$1 to the function.

Anyone notice this?

Govert van Drimmelen

unread,
Nov 8, 2022, 12:37:41 AM11/8/22
to exce...@googlegroups.com
Hi Mike,

This is definitely not something I expect to work different between versions.

Your example is not a worksheet function (it returns 'void', so looks more like a macro), so I'm guessing your actual code looks different, or you are not calling this from a cell formula.

Could you show a small example that I can try?

'Excel 365' is just a different way of licensing the product, but the desktop Excel application is still the same as before (with upgrades etc). The web-based Excel is quite different and does not support Excel-DNA add-ins at all.

-Govert


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/ccd12085-80d3-4a8a-b60c-e9e7cd93eecfn%40googlegroups.com.

Ming Liu

unread,
Nov 9, 2022, 3:16:03 PM11/9/22
to exce...@googlegroups.com
Thanks for your response.

My function is like this:

public static string Test(string str, object obj) 
{
....
}

Before, when I call this function from the sheet like

=Test(A1:B2, C1:B2)

The parameters str and obj will get range area like "A1:B2" and "C1:B2".

Now str will be the value in A1. obj will be a two dimensions of array object[2,2] which has  the values in C1:B2


You received this message because you are subscribed to a topic in the Google Groups "Excel-DNA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/exceldna/GjPkPiTNamE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/CABCjBXNiVQyizoYaRg6sjnR_bV2BF9E54qPXtSx0cy53GYsW2A%40mail.gmail.com.

Govert van Drimmelen

unread,
Nov 9, 2022, 3:39:39 PM11/9/22
to exce...@googlegroups.com

To get the parameter values you show, you can call the function from the sheet as

    =Test("A1:B2", "C1:B2")

 

There are indeed ways to get an “ExcelReference” object as the argument value, but that would never happen if your parameter has type ‘string’ and needs a special attribute on the parameter too.

 

None of this has changed between Excel or Excel-DNA versions.

 

-Govert

Ming Liu

unread,
Nov 9, 2022, 4:23:10 PM11/9/22
to exce...@googlegroups.com
The problem is my users sheets don't work anymore after they upgrades to Office 365.

Govert van Drimmelen

unread,
Nov 9, 2022, 5:21:22 PM11/9/22
to exce...@googlegroups.com

One thing that changed with newer Excel that might be affecting you, is the ‘dynamic arrays’.

Functions that return array results will now ‘spill’ over many cells.

It’s a big topic – but you’ll find a lot of information on the web.

 

If you can make a small add-in and matching workbook that you can post on GitHub or somewhere, which works under old Excel and not under new Excel, then I can have a look.

Reply all
Reply to author
Forward
0 new messages