This project has moved and is read-only. For the latest updates, please go here.

Object ExcelDna.Integration.ExcelReference cannot convert to NetOffice.ExcelApi.Range.

Nov 19, 2012 at 11:50 AM


I try write Excel function using ExcelDna and NetOffice

For example:


[ExcelFunction(Description = "My description.", IsMacroType = true)]
        public static object GetSize( [ExcelArgument(AllowReference = true)]object cell) {
            if (!(cell is ExcelReference)) {
                return ExcelError.ExcelErrorValue;
            Excel.Range  rng = (Excel.Range)cell;           
            return something;            

But I cannot convert xcelDna.Integration.ExcelReference to NetOffice.ExcelApi.Range

I use ExcelDna 0.29, NetOffice, Excel 2010 32bit, Win7 64bit and Visual Studio 2008 Pro.

Can you help me? Am I doing something wrong?

Thanks for answer.




Nov 19, 2012 at 12:50 PM


at first: NetOffice has no helpful examples to use Excel-DNA and NetOffice in one solution(failed). as far i known Govert van Drimmelen provides some example solutions here. (Govert are you read this and help?)  

try to use:

NetOffice.ExcelApi.Range range = new NetOffice.ExcelApi.Range(null, cell);

NetOffice wraps all references in own wrapper classes. this is why can't convert a proxy in this way.



Nov 20, 2012 at 6:52 AM


thanks for answer

row NetOffice.ExcelApi.Range range = new NetOffice.ExcelApi.Range(null, cell); is now OK

But variable has throw an exeption of type 'System.Runtime.InteropServices.COMException' for all property.

I writed similar function in my past computer and worked correctly, (with Excel 2002)

Any ideas?





Nov 21, 2012 at 7:30 AM


To convert from a native ExcelReference to a COM Range object I need a helper like discussed here:

Not it's OK.