Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation Question: Insert a row
Message
 
 
To
08/04/2007 16:42:32
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01213304
Message ID:
01213315
Views:
23
>I am trying to insert a row into a spreadsheet. I am most of the way there but need some help...
>
>I have an object references to Excel, the workbook, and the selected worksheet:
> loExcel
> loWorkbook
> loWorkSheet
>
>
>I want to insert some rows after a given row, let's say row 8, so I issue:
> loWorksheet.Range("A8").Select
>
>Then I insert a row:
> loExcel.Selection.EntireRow.Insert()
>
> The above line of code works, but it inserts a row using the characteristics of the previous row. I want to insert a row using the characteristics of the following row.
> Using the macro recorder, I found that Excel inserts using the characteristics of the following row like this:
>
>Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromRightOrBelow
>
>But I cannot figure out how to convert this Excel syntax to a syntax that VFP will accept.
>
>
>
>Also, is there a way to insert multiple lines at one time rather than one row at a time? I will know in advance how many rows I want to insert and it would be nice to be able to tell Excel: "please insert 500 rows" rather than ask Excel 500 times to insert 1 row.
>
>Many thanks in advance.

Try loSheet.rows("1:" + alltrim(str(m.lnLines + m.lnOffset))).insert(xlShiftDown)

e.g. specify from and to ranges to insert, say, 5:10 will insert rows starting after 5 row.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform