View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
hCoded hCoded is offline
external usenet poster
 
Posts: 1
Default Accessing value in a range using Automation in a C# DLL

Greetings I followed the steps in this blog here to create my C# DLL that
contains my excel 2003 UDFs:

http://blogs.msdn.com/eric_carter/ar...01/273127.aspx

The problem I am having is when I pass in a range of cells from excel into
my function which resides inside my Automation DLL I just cannot figure out
how to access the cell values individually. Here is an example of my
functions:

public double SecondValueIs(object Range)
{
int SecondCell= 0;
Excel.Range r = Range as Excel.Range;

//What code do I put here to get the second cell if its a one
row range?
//lets say that I passed in A1:A5?
//
//object value = r.Cells[1,2].value DOES NOT work no VALUE
method ...
//string value = r.Cells[1,2] DOES NOT work .. cant convert COM
object to string ...


return SecondCell;
}

If I look inside r.FormulaLocal for instance I can see a list of my cell
values but I cant convert or otherwise manipulate them. There HAS to be a
way to do so. What am I doing wrong?

Thank you in advance for your time.

~Rob.