View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
HSalim[MVP] HSalim[MVP] is offline
external usenet poster
 
Posts: 70
Default vbscript and Excel

Hi
I need to work with an Excel file using vbscript.

Here is a code snippet:
Set XL = CreateObject("Excel.Application")
XL.Application.Workbooks.Open "c:\temp\Myfile.xls"
XL.Visible = True

'rename sheet etc
XL.ActiveSheet.Name = "PayrollInfo"
XL.Cells.UnMerge

'Add new column headings.. Current data in cols a-e
XL.Range("F1:I1") = Array("TrxDate", "Co", "LineNum", "Acct")

'get the last row of data


With XL
Set rng =.Range("A1:F" & .Cells(.Rows.Count, "A").End(xlUp).Row)

This line fails with error 1004 - Application or object defined error


What am I doing wrong? Thanks in advance for your advice.

REgards
Habib

--
www.DynExtra.com
A resource for the Microsoft Dynamics Community
Featuring FAQs, File Exchange and more
Current member count: 40
--------------------------------------------
Share your knowledge. Add your favorite questions and answers
Help add questions to this site! We want Your input.
--------------------------------------------