Range.Columns property error encountered after upgrading to new version of exceldna

26 views
Skip to first unread message

Ash Hui

unread,
Jul 19, 2024, 11:15:07 PM (2 days ago) Jul 19
to Excel-DNA

I recently encountered a problem using the latest version
When the range object uses the Columns attribute, it cannot be used normally.

Range.Columns Property (Microsoft.Office.Interop.Excel) | Microsoft Learn

I used to use "rangeObj.Columns(1)" to get the first column of data in the range, but now when I use the same code, an exception occurs: "System.MissingMemberException"
Previously the following code worked fine:
dim result = rangeObj.Columns(1).value
Now i can only:
Dim temp = rangeObj.Columns(1)
dim result = temp.value

This problem feels very strange to me. This is the only problem I have left after upgrading to the new version. Please help me confirm the reason.


It is not possible to upload attachments here, so I created this issue and attachments on github, see here for details:

[Range.Columns property error encountered after upgrading to new version of exceldna · Issue #705 · Excel-DNA/ExcelDna](https://github.com/Excel-DNA/ExcelDna/issues/705)

Ash Hui

unread,
Jul 20, 2024, 10:52:34 AM (2 days ago) Jul 20
to Excel-DNA

I tested it many times and finally found a way to get the specified range items normally.
That is, rng(1) must be explicitly assigned to a range variable:
Dim a As Range = rng(1)
Then you can use:
a.Address

If you directly use chain calls or implicit definitions, you will not be able to obtain the corresponding attributes normally:
rng(1).Address 'will false
or:
Dim a = rng(1)
a.Address 'will false

I don't know why this happens when I use the new version of exceldna library in my new project. I didn't encounter this problem in the old project.


The same is true for range.Worksheet.Parent.Name, and chain calls cannot be made.
A temporary variable must be explicitly declared before its properties can be called
dim a as workbook = range.Worksheet.Parent
a.Name

I don’t know if there’s something wrong with my usage, or if it’s just like this in the new version.

Reply all
Reply to author
Forward
0 new messages