Friday, November 19, 2010

VBScript Code - Writing values to excel

Write the below code in a notepad and save it as a .vbs file. Either run it from command prompt or run it by double-clicking on it.

VBScript Code - Writing values to excel

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Add()

objWorkbook.worksheets("Sheet1").Cells(1, 1).Value = "Testing a value"
objWorkbook.SaveAs("C:\Book2.xlsx")
objExcel.Quit