Posts Tagged ‘Excel’

How to add a sheet in Excel through VB Scripting.

Please find the code.

Set obj_ExcelSheet = CreateObject(“Excel.Application”)’ creating the excel object

obj_ExcelSheet.visible = True

obj_ExcelSheet.SheetsInNewWorkbook = 1 ‘ no of sheets to be added

obj_ExcelSheet.Workbooks.Add() ‘ actually adding the sheet to the file

obj_ExcelSheet.Worksheets(1).Activate ‘ make the sheet no-1 activate

obj_ExcelSheet.Activesheet.Name = “Check” ‘name of the sheet

obj_ExcelSheet.ActiveWorkbook.saveas (“C:\Documents and Settings\username\Desktop\MF.xls”) ‘saving the file in desired location.

obj_ExcelSheet.quit ‘ quiting from the excel.

Set obj_ExcelSheet = nothing

Please provide your feedback.

Reblog this post [with Zemanta]
%d bloggers like this: