Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default using Addin in C# To Change a Range of Cells

Hello,
I am Trying to Write an Addin Function in Excel using C# (.Net 2005),
that will get 2 parameters :
1. A basic data for the function, in a single cell.
2. A Range of cells, that the function will put the output into.

A Want the Range of cells that is the output of the function, to change
dynamically when I change the cell of the input.

I tryed a simple example, as following :

public object WriteArea(int start, object Range)
{
Microsoft.Office.Interop.Excel.Range r;

try
{
r = Range as Microsoft.Office.Interop.Excel.Range;
}
catch
{
return "Not A Range";
}
int startRow = -1;
int startCol = -1;
int EndRow = -1;
int EndColoum = -1;
startRow = r.Row;
startCol = r.Column;
EndRow = r.EntireRow.Count + startRow;
EndColoum = r.EntireColumn.Count + startCol;
if (!r.Cells.AllowEdit)
{
return "Not Allowed";
}
try
{
for (int i = 1; i <= r.EntireRow.Count; i++)
{
for (int k = 1; k <= r.EntireColumn.Count; k++)
{
try
{
if (!((Range)r[i, k]).AllowEdit)
{
return "Editing is not allowed !";
}
((Range)r[i, k]).Value2 = start++;
}
catch (Exception e)
{
return e.Message;
}
}
}
}
catch (Exception e)
{
return e.Message + " U9";
}
return "start Row is " + startRow.ToString() + "start Coloum is
" + startCol.ToString() +
"end row is " + EndRow.ToString() + "end coloum is " +
EndColoum.ToString();
}


It works well when I first Define the function in excel (2007), but when I
change the value of the cell that is the input (the start) The values of the
output range doesn't change accordingly.

I get the Exception :

Exception from HRESULT: 0x800A03EC
what can I do ?

thanks, shahar.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default If I wasn't clear, I am using an automation add-in.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change range from cells to sheet? JBW Excel Worksheet Functions 1 November 7th 07 03:33 PM
Change data value in a range of cells turen Excel Programming 5 September 5th 07 06:54 PM
change range of cells to another currency Max-SR Excel Worksheet Functions 3 December 31st 05 07:18 PM
How do I change the year in a range of cells Lee D Excel Discussion (Misc queries) 6 November 29th 05 08:32 PM
Copy cells into range of cells until cell change mdeanda Excel Worksheet Functions 1 April 22nd 05 08:41 PM


All times are GMT +1. The time now is 12:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"