Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Automation
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, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Automation
hi Leon,
I'm unfamiliar with "get_offset" & "set_value" but think the line could work if changed from "range.Cells.get_Offset(0, 0).set_Value(Missing.Value, "ASDF");" to "range.Cells.get_Offset(0, 0).resize(1,1).set_Value(Missing.Value, "ASDF");" hth Rob __________________ Rob Brockett NZ Always learning & the best way to learn is to experience... " wrote: 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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using Excel with automation | Excel Discussion (Misc queries) | |||
Supressing the ctrl-c and other keys during word automation in automation | Excel Programming | |||
Excel automation | Excel Programming | |||
Excel OLE automation | Excel Programming | |||
Excel automation | Excel Programming |