ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete row in Excel 2002 worksheet (https://www.excelbanter.com/excel-programming/329497-delete-row-excel-2002-worksheet.html)

RuthC

Delete row in Excel 2002 worksheet
 
In VFP 7, my application can perform the following command correctly using
Excel 2000, but not in Excel 2002:

goExcel = CREATEOBJECT("Excel.Application")
WITH goExcel
.Workbooks.Open(lcXlsName)
.Rows("5:5").Delete
ENDWITH

If I record this task in an Excel Macro and edit it using the Macro Editor,
I get the following:

.Rows("5:5").Select
.Selection.Delete Shift:=PxlUp
.Range("A5").Select

If I add <spaceShift:=PxlUp after the Delete command, the compiler returns
a syntax error.

How can I run Excel commands in VFP 7 like this? What is the correct syntax
for it?

Thanks


Tom Ogilvy

Delete row in Excel 2002 worksheet
 
Try

goExcel = CREATEOBJECT("Excel.Application")
WITH goExcel
.Workbooks.Open(lcXlsName)
.ActiveSheet.Rows("5:5").Delete
ENDWITH

The constant doesn't have a "P" in it

? xlshiftup
-4162
? xlup
-4162

if you are using late binding, use the number (-4162) instead of the named
constant, but when deleting a row, you don't need it. The only option is to
shift up.

--
Regards,
Tom Ogilvy



"RuthC" wrote in message
...
In VFP 7, my application can perform the following command correctly using
Excel 2000, but not in Excel 2002:

goExcel = CREATEOBJECT("Excel.Application")
WITH goExcel
.Workbooks.Open(lcXlsName)
.Rows("5:5").Delete
ENDWITH

If I record this task in an Excel Macro and edit it using the Macro

Editor,
I get the following:

.Rows("5:5").Select
.Selection.Delete Shift:=PxlUp
.Range("A5").Select

If I add <spaceShift:=PxlUp after the Delete command, the compiler

returns
a syntax error.

How can I run Excel commands in VFP 7 like this? What is the correct

syntax
for it?

Thanks




Alok

Delete row in Excel 2002 worksheet
 
Ruth,
I admit I have not automated Excel from VFP but you may want to try the
following
instead of .Rows(5:5).Delete, try .Rows("5:5").EntireRow.delete

Also the other error you are getting may be due to the wrong constant value
and hence you may like to try
Excel.xlUp instead of PxlUp

Alok Joshi

"RuthC" wrote:

In VFP 7, my application can perform the following command correctly using
Excel 2000, but not in Excel 2002:

goExcel = CREATEOBJECT("Excel.Application")
WITH goExcel
.Workbooks.Open(lcXlsName)
.Rows("5:5").Delete
ENDWITH

If I record this task in an Excel Macro and edit it using the Macro Editor,
I get the following:

.Rows("5:5").Select
.Selection.Delete Shift:=PxlUp
.Range("A5").Select

If I add <spaceShift:=PxlUp after the Delete command, the compiler returns
a syntax error.

How can I run Excel commands in VFP 7 like this? What is the correct syntax
for it?

Thanks



All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com