Does anyone have more information on the CopyOrigin parameter of the
NamedRange.Insert method?
I'm using VSTO 2005 and the task I'm trying to perform in Excel 2003 is
simple.
I have a NamedRange object, declared Globally, called reqItemRange. It
spans 1 row and 18 columns, (A2:R18). I'm simply trying to insert a new row
into the top of the range. On an Action Pane there is a button that calls
the following code in its onclick event. I also redefine the NamedRange
using the RefersToR1C1 property (this works).
int startRow = 2;
Excel.Range startCell =
(Excel.Range)Globals.Sheet1.Cells[startRow, 1];
startCell.Select();
int row = 0;
row = Globals.Sheet1.reqItemRange.Row;
Globals.Sheet1.reqItemRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Type.Missing);
Globals.Sheet1.reqItemRange.RefersToR1C1 = "=R" +
startRow.ToString() + "C1:R" + (Globals.Sheet1.reqItemRange.Rows.Count +
(Globals.Sheet1.reqItemRange.Row - 1)).ToString() + "C18";
startCell.Select();
The first click of the button performs well, although the new row doesn't
contain the drop-down lists in the cells that were in the original row in the
NamedRange. Subsequent clicks on the button causes multiple new rows to be
added. The number of rows added seems to be equal to the number of rows
previously in the NamedRange before clicking the button. I've tried
substituting different values for the Insert methods second argument (object
CopyOrigin).
For example, if I pass -1 as the CopyOrigin argument the Insert does copy
the drop-downs in the original range's rows but the multiple row additions
still occurs on subsequent button clicks. If I pass 0 as the CopyOrigin
argument the Insert doesn't copy the drop-downs and still adds multiple rows
on susequent clicks.
Does any know what this CopyOrigin argument actually does?

Signature
Somewhere on the Delaware River
njappboy - 30 May 2006 19:09 GMT
It would seem that the CopyOrigin parameter is supposed to be an enumeration
of the type Microsoft.Office.Interop.Excel.XlInsertFormatOrigin . Someone at
Redmond needs to update the Insert method docs with this bit of information.

Signature
Somewhere on the Delaware River
> Does anyone have more information on the CopyOrigin parameter of the
> NamedRange.Insert method?
[quoted text clipped - 38 lines]
>
> Does any know what this CopyOrigin argument actually does?