Bug Article
[
Home
|
Contents
|
Search
|
Post
|
Reply
| Previous | Next ]
Subject:
Add a new sheet in excel workbook using vbscript
Name:
naina
Date:
Wednesday, October 23, 2002
Email (spam proof):
Email the originator of this post
Product:
Web Site
Bug:
How to wirte this code in vbscript for adding just 1 new sheet in workbook Dim Cnn Dim RstCNET Dim StrSQL Dim XLSPath Dim shtName Dim ExcellApp Dim oBook Dim osheet Dim CellCnt Dim IRow 'Path for storing Excel Files 'XLSPath = "e:\excel\" Set ExcellApp = CreateObject("Excel.Application") 'first Set the Book StrFileName = XLSPath & "CNETDailyReport" & CStr(Right(Date, 4) & Left(Date, 2) & Mid(Date, 4, 2)) & ".xls" Set oBook = ExcellApp.Workbooks.Add shtName = Mid(Date, 4, 2) Set osheet = oBook.Worksheets(1) Sheet.Add.Name = shtName 'Sheets(shtName).Move After:=Sheets(Sheets.Count) 'Sheets("Sheet1").Range("A1:A5").Copy _ 'Sheets(shtName).Range("A1") 'Setting Field Name oBook.SaveAs StrFileName Set oBook = Nothing ExcellApp.Quit Set ExcellApp = Nothing