I tried this code to create an excel sheet.
Set ExcelObject = CreateObject("Excel.Application")
ExcelObject.visible = True
ExcelObject.WorkBooks.Add
ExcelObject.Sheets(1).Cells(1,1).value = "My first excel"
But i want more than one excel to be generated So i tried this code-
Set ExcelObject = CreateObject("Excel.Application")
For x= 1 to 5
ExcelObject(x).visible = True
ExcelObject(x).WorkBooks.Add 'Adds a workbook to an excel object
x=x+1
ExcelObject.Sheets(1).Cells(1,1).value = "My first excel"
But it is not working.Please help!
Your code has some errors:
You missed
Next xYou don’t have to increment
xsince you useFor..Nextstatement.Next xwill do that for you.Working code:
For
VB.NET:For
VBScript: