L
leon800219
Hi all,
The following code snippet will insert a row above the first empty
row, and then copy the above row contents to the newly inserted row.
The problem is when the last line was invoked, the value "ASDF"
applies to the entire row instead of only the first cell, and when I
apply the value to offset(0, >n) I got an execption "0x800A03EC". How
can I set value to specific cell in the newly inserted row?
range = oSheet.get_Range("A1", Missing.Value);
range = range.get_End(Excel.XlDirection.xlDown).get_Offset(1,
0);
range.EntireRow.Insert
Excel.XlInsertShiftDirection.xlShiftDown,
Excel.XlInsertFormatOrigin.xlFormatFromLeftOrAbove);
// Move range to the above row, then copy it to the newly inserted
row
range = range.EntireRow.get_Offset(-1, 0);
range.get_Offset(-1, 0).Copy(range);
range.Cells.get_Offset(0, 0).set_Value(Missing.Value, "ASDF");
Thanks,
The following code snippet will insert a row above the first empty
row, and then copy the above row contents to the newly inserted row.
The problem is when the last line was invoked, the value "ASDF"
applies to the entire row instead of only the first cell, and when I
apply the value to offset(0, >n) I got an execption "0x800A03EC". How
can I set value to specific cell in the newly inserted row?
range = oSheet.get_Range("A1", Missing.Value);
range = range.get_End(Excel.XlDirection.xlDown).get_Offset(1,
0);
range.EntireRow.Insert
Excel.XlInsertShiftDirection.xlShiftDown,
Excel.XlInsertFormatOrigin.xlFormatFromLeftOrAbove);
// Move range to the above row, then copy it to the newly inserted
row
range = range.EntireRow.get_Offset(-1, 0);
range.get_Offset(-1, 0).Copy(range);
range.Cells.get_Offset(0, 0).set_Value(Missing.Value, "ASDF");
Thanks,