Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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
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
Using Excel with automation Thomas Bodell Excel Discussion (Misc queries) 5 May 8th 09 03:09 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Excel Programming 0 July 19th 07 10:10 PM
Excel automation Kaustav Excel Programming 1 November 28th 06 05:26 AM
Excel OLE automation Nicolas[_2_] Excel Programming 1 August 19th 05 07:17 PM
Excel automation zino Excel Programming 1 December 29th 04 11:55 AM


All times are GMT +1. The time now is 02:53 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"