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

Nov 20, 2012 at 8:42 AM

Hello,

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 1.5.1.2, Excel 2010 32bit, Win7 64bit and Visual Studio 2008 Pro. 

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

Can you help me? Am I doing something wrong?

I wrote same question on NetOffice: http://netoffice.codeplex.com/discussions/403771

Thanks for answer.

Radek

 

Coordinator
Nov 20, 2012 at 4:14 PM

Hi Radek,

To convert from a native ExcelReference to a COM Range object you need a helper like discussed here: https://groups.google.com/group/exceldna/browse_frm/thread/ceacc4228b3b99ad.

Then for the NetOffice conversion you need to wrap the result in something like:

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

-Govert

Nov 21, 2012 at 6:28 AM

Hi Govert,

Thanks for answer, now it's OK

Radek