View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David Wake David Wake is offline
external usenet poster
 
Posts: 1
Default Newbie: Can't delete to left with WScript

I'm a complete MS newbie trying to automate some processing of Excel
worksheets. I can insert values fine, but deleting doesn't work.

Here is my script, which I'm running via the Windows Script Host:


set xapp = WScript.CreateObject("Excel.Application")
xapp.Visible = True
set workbook = xapp.Workbooks.Open("Z:\home\dwake\Test.xls")
set worksheet = workbook.Worksheets("sheet1")
worksheet.Cells(1,1).Value = "Test"
worksheet.Cells(1,1).Value = "Test2"
worksheet.Range("A1:A2").Delete Shift:=xlToLeft 'this line causes problems
workbook.save()
workbook.Close(false)
xapp.Quit()


Everything runs fine if I comment out the Delete line. However, with
it I get the following error:

Script: Y:\Test.vbs
Line: 7
Char: 39
Error: Expected Statement
Code: 800A0400
Source: Microsoft VBScript compilation error.

What am I doing wrong, and how can I fix it?

Thanks!

David