0

I am writing a Excel 2003 automation addin using c#.

I have followed this article http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/writing-user-defined-functions-for-excel-in-net.aspx

Every thing works including passing excel range object as parameter. But I wasn't able to return a range object from my function. My knowledge is very limited on the subject matter, will appreciate any inputs.

Yahia
  • 69,653
  • 9
  • 115
  • 144
RajeevNy
  • 28
  • 6

1 Answers1

1

Since you don't show any source code it is hard to tell what's wrong - for returning Excel Range use object[,] as the return type of your UDF.

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • I was trying to get a instance of Microsoft.Office.Interop.Excel.Range. But since its a interface thats not possible. I wonder how this two dimensional object array will translate into Excel range. I am using VBA wrapper function to call the Addin UDF. – RajeevNy Nov 23 '11 at 19:03
  • @RajeevNy I don't know what you mean... Excel will translate that into a Range objectwith columns and rows... implement and test it first without a VBA wrapper, then checkout how VBA deals with it... – Yahia Nov 23 '11 at 19:09
  • 1
    This is what I tried and it worked. Thankspublic object[,] ReturnRange(string input) { object[,] output = new object[,]{{1,2,3}, {"A","B", "C"}}; return output; } – RajeevNy Nov 23 '11 at 19:32