Dave
Sun Apr 09 18:18:40 CDT 2006
Try;
Option Explicit
Dim filePath, oExcel, oSheet, intLastRow, intRow
Const xlUp = -4162
intRow = 3
intLastRow = 6
filePath = "c:\Test.xls"
Set oExcel = CreateObject("Excel.Application")
'oExcel.Visible = True
oExcel.Workbooks.Open filepath
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
oSheet.Rows("" & intRow & ":" & intLastRow & "").Delete xlUp
oExcel.DisplayAlerts = False
oExcel.ActiveWorkbook.SaveAs filePath
oExcel.ActiveWorkbook.Close
oExcel.Quit
set oSheet = Nothing
Set oExcel = Nothing
FYI;
you don't want () after Select
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
<svein.dale@networks.no> wrote:
|
| Hello,
|
| In the below code lines I get a type mismatch error message when I try
| to use variables inside
| the quotes, I need to programmatically stuff in variables if my script
| is going to work, like this
|
| objExcel.Rows("intRow:intLastRow).Select() 'Doesn't work.
| objExcel.Rows("44:91").Select() 'Works.
| objExcel.Selection.Delete
|
| Seems only regular numbers works inside the quotes.
|
| Any idea of what to do ?
|
| TIA
|
| Svein,Oslo
|