ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessing value in a range using Automation in a C# DLL (https://www.excelbanter.com/excel-programming/389314-accessing-value-range-using-automation-c-dll.html)

hCoded

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.



All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com