Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After doing intense research on the net, I finally found out that I cannot
simply use VSTO 2008 ThisAddIn to create UDFs (for Excel 2007), at least not without writing any further VBA code to call the UDF defined. I thought this was possible, but read that actually to write UDFs without VBA I either have to use COM AddIns or Automation AddIns. I'd be happy to be proved I'm wrong. So I wrote an Automation AddIn for Excel 2007 (using C#). It again took me a long time to understand that unlike with VB.NET in C# I simply cannot use myRange.Value but must use myRange.Value2 instead. Fact is, myRange.Value simply doesn't exist as a public accessible field in Microsoft.Office.Interop.Excel. (Of course all the code examples on the net fail to mention this fact.) How do I then access and modify the value of a cell? The following code example works fine: public String Foo(object Range) { Type type = Range.GetType(); return type.ToString(); } However, the next example does not work: public String Foo2(object Range) { Excel.Range rng = (Excel.Range) Range; Object obj = (Object) rng.Value2; // (Object)rng.Cells[1,1].Value2 does not work either Type type = obj.GetType(); return type.ToString(); } The result in Excel is #VALUE! independent of what type the method parameter actually is. I have no clue whatsoever why I cannot access rng.Value2. Can anyone explain? Thanks. Fabz |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with Range.Value2, Range.Text and UDFs | Excel Programming | |||
Deploying Excel 2007 VSTO Addin | Excel Programming | |||
0x800a03ec - VB 2005 or VB 2008 & Excel 2007 (Range Text) (AddData | Excel Programming | |||
Excel 2007 Add-in with VSTO | Excel Programming | |||
Excel & C# NullReference Error when trying to set Range.Value2 | Excel Programming |