vbscript >> rename worksheet in excel

by nikunj shah » Thu, 30 Jun 2005 23:23:28 GMT

how can I rename a worksheet in excel using vbscript.

thankx

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...


vbscript >> rename worksheet in excel

by Dave Patrick » Fri, 01 Jul 2005 00:03:35 GMT


Option Explicit
Dim filePath, oExcel, oSheet

filePath = "c:\Test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open(filepath)
Set oSheet = oExcel.ActiveWorkbook.Worksheets(1)
oSheet.Name = "Some Sheet Name"
oExcel.ActiveWorkbook.Save
oExcel.ActiveWorkbook.Close
set oSheet = Nothing
Set oExcel = Nothing


--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


| how can I rename a worksheet in excel using vbscript.
|
| thankx
|
| **********************************************************************
| Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
| Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...





Similar Threads

1. rename worksheet in Excel for Mac - Excel

2. Renaming worksheets in Excel before doing DTS

Anybody could help me ?
I have 286 tables which contains only 1 worksheet - but the name is 30 char 
long and contains some spaces.

I need to change it to simple name like 'datasheet' so it will work in my 
DTS loop ....

But somehow the activeX did not work as I want it to.

Function Main()
 'use script to rename all sheets to a common name
              dim xlObj
              Set xlObj = CreateObject("Excel.application")
              xlObj.Workbooks.Open 
DTSGlobalVariables("gv_FileFullName").value
              xlObj.ActiveWorkbook.Sheets(1).Name = "DataSheet"
              xlObj.ActiveWorkbook.Save
              xlObj.Quit
              Set xlObj = Nothing
              Main = DTSTaskExecResult_Success
End Function



Any help will be greatly appreciated.


3. how do i create a macro to rename worksheets in excel? - Excel

4. Using information from one worksheet, to rename inserted worksheet

I am trying to automate a worksheet as follows :

From a register of information (sheet 1) Insert a new worksheet, move it 
into the position immediately right of sheet 1 (making it the 2nd sheet 
within the workbook), then rename the sheet using a number in a cell  on 
Sheet 1.

What I am ultimately trying to achieve is as numbers are added to the list 
on the register sheet this information is then used to rename new worksheets 
as they are added.

If any one can help I would appreciate it.

5. Report Generation Tutorial, cannot find Rename Worksheet VI, Add Worksheet VI,

6. Renaming Excel Worksheet Names after creation in VBA

Hello,

I created an excel spreadsheet using VBA Code.  It creates 3 sheets in one 
workbook acquiring the information from queries.  However, when the excel 
workbook is created and I open the file that VBA saved on my hard drive, it 
says that it had to "repair" the workbook, that there were invalid sheet 
names.  As a result, it named the sheets "Recovered_Sheet1", 
"Recovered_Sheet2" and so on.  I would like these individual sheets to be 
renamed to the queries that I got the data from. 

Is this possible within VBA?

Thank you!
MN

7. Renaming Excel Worksheets via ADO.NET - ADO.Net

8. Excel 2007 rename my worksheet

I saved my original workbook created in 2003 to Excel 2007.  This workbook 
contains link and charts.

When I open the workbook in 2007.  The Excel from time to time rename my 
chart worksheet name

eg. I name the worksheet that contain a chart as :GroupChart, Excel change 
its name Chart2 etc.

What is the problem?  Now I have to keep renaming these worksheets, but 
everytime I save and open the workbook again the workname is changed.