How to move NamedRange to Excel - VSTO is not VBA

I broke through the network and, according to the documentation, there is no way to move NamedRange: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange_methods(v=vs.80).aspx

I have the following code that copies cell data over multiple lines:

activeSheet.Range[leftColumn + startRow, rightColumn + endRow].Copy();
//activeSheet.Range[leftColumn + startRow, rightColumn + endRow].Delete();
Range newRange = activeSheet.get_Range(leftColumn + (startRow + RowsToMoveDown.Count), rightColumn + (endRow + RowsToMoveDown.Count));
newRange.PasteSpecial(XlPasteType.xlPasteAll, XlPasteSpecialOperation.xlPasteSpecialOperationNone, Missing.Value, Missing.Value);

NamedRange is the cells that I copy and paste, it moves the values โ€‹โ€‹of the cells along several lines, but since its copy leaves the data in the above cells, and the Delete method throws an exception. However, the real problem is that after moving the cells, I created a NamedRange:

rnArea = activeSheet.Range[leftColumn + startRow , rightColumn + (MyData.Values.Length + startRow)];
Name name = activeBook.Names.Add(uniqueName, rnArea);

Still refers to the original cell range (location before I moved the cells down).

How to programmatically move NamedRange in C # VSTO 4.0?

, , , .

EDIT:

Doug Glancy VBA VSTO # :

for (int i = 0; i < activeWorkbook.Names.Count; i++)
{
name = activeWorkbook.Names.Item(i + 1);
Debug.Write(name.Name.ToString());

System.Diagnostics.Debug.Write(name.RefersTo.ToString() + Environment.NewLine);
//prints out "Sheet1!$A$1:$A$25"
name.RefersTo = "Sheet1!$A$2:$A$26";
System.Diagnostics.Debug.Write(name.RefersTo.ToString());
//prints out "Sheet1!$A$2:$A$26"
}

NamedRange RefersTo, , NamedRange Excel NamedRange DropDownList?!?!

+3
1

"" , . , VBA:

Sub MoveNamedRange()
ActiveSheet.Names.Add Name:="test", RefersTo:="=$A$1"
Debug.Print ActiveSheet.Range("test").Address
ActiveSheet.Names.Add Name:="test", RefersTo:="=$A$2"
Debug.Print ActiveSheet.Range("test").Address
End Sub

:

$A$1
$A$2

EDIT - C ! VS 2010 #. Workbook, . , Type.Missing VS 2010, , , :

private void Sheet1_Startup(object sender, System.EventArgs e)
        {
            Globals.Sheet1.Names.Add("test", Globals.Sheet1.Range["A1"], System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
            MessageBox.Show(Globals.Sheet1.Range["test"].Address);
            Globals.Sheet1.Names.Add("test", Globals.Sheet1.Range["A2"], System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
            MessageBox.Show(Globals.Sheet1.Range["test"].Address);
        }
+4

All Articles