Returning #N/A from an RTD server

484 views
Skip to first unread message

Simon

unread,
Jun 30, 2011, 7:46:13 AM6/30/11
to Excel-DNA
Hi,

Having had a go at my first RTD server, I have found that if I return
ExcelDna.Integration.ExcelError.ExcelErrorNA as an item in the array
returned by RefreshData(), Excel shows the result as 42. I guess this
is the constant used for ErrorNA.

Is this a bug?

Simon.

Govert van Drimmelen

unread,
Jun 30, 2011, 9:35:07 AM6/30/11
to Excel-DNA
Hi Simon,

Yes, ExcelErrorNA = 42.
The RTD stuff is all COM, and the ExcelError enum is related to the C
API, so these don't mix-and-match at all.
You can probably set some COM errors into your result array, I'm not
sure how though. "System.Runtime.InteropServices.ErrorWrapper" might
be a starting point for your research.

-Govert

Simon

unread,
Jun 30, 2011, 10:43:33 AM6/30/11
to Excel-DNA
Hi Govert,

Thanks for the COM pointer (no pun intended!), the following article
explains the problem nicely...

http://xldennis.wordpress.com/2006/11/29/dealing-with-cverr-values-in-net-part-ii-solutions/

The following code seems to work...

Enum CVErrEnum As Int32
ErrDiv0 = -2146826281
ErrNA = -2146826246
ErrName = -2146826259
ErrNull = -2146826288
ErrNum = -2146826252
ErrRef = -2146826265
ErrValue = -2146826273
End Enum

and

resultRTDArrayItem = New
System.Runtime.InteropServices.ErrorWrapper(CVErrEnum.ErrNA)

As I am not a COM expert, could this cause a memory leak or is .net
clever enough to clean up?

Simon.
Reply all
Reply to author
Forward
0 new messages