NisHera
11 years agoValued Contributor
Create new excel from data
Hi
I was trying to create an XL using some data in script
but failed following are my coding please help me correcting it
Sub Main
Dim fileName, sheetName
fileName ="C:\N2014_1\TaxCalculation\logs26.xlsx"
sheetName ="Logs1"
Call WriteLogs(fileName,sheetName)
End Sub
Sub WriteLogs(fname,sname)
Dim app,book,sste, row, col
Set app = CreateObject("Excel.Application")
Set book = app.Workbooks.Add()
book.saveAs fname
Set app = Sys.OleObject("Excel.Application")
Set book = app.Workbooks.Open(fname)
Set sste = book.Sheets(sname) '------hear it says Subscript out of range ????-----------
app.Application.Visible = True
app.DisplayAlerts = False
For row=0 to 5
for col = 0 to 4
app.book.sheet.Cells(row,col) =row&","& col
Next
Next
Book.SaveAs fname
.Book.Close
app.Appliaction.Quit
End Sub
I was trying to create an XL using some data in script
but failed following are my coding please help me correcting it
Sub Main
Dim fileName, sheetName
fileName ="C:\N2014_1\TaxCalculation\logs26.xlsx"
sheetName ="Logs1"
Call WriteLogs(fileName,sheetName)
End Sub
Sub WriteLogs(fname,sname)
Dim app,book,sste, row, col
Set app = CreateObject("Excel.Application")
Set book = app.Workbooks.Add()
book.saveAs fname
Set app = Sys.OleObject("Excel.Application")
Set book = app.Workbooks.Open(fname)
Set sste = book.Sheets(sname) '------hear it says Subscript out of range ????-----------
app.Application.Visible = True
app.DisplayAlerts = False
For row=0 to 5
for col = 0 to 4
app.book.sheet.Cells(row,col) =row&","& col
Next
Next
Book.SaveAs fname
.Book.Close
app.Appliaction.Quit
End Sub