Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
Rename Worksheet in excel through codes
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 05-15-2007, 02:33 AM
WalangAlam
 
Posts: n/a
Default Rename Worksheet in excel through codes

How to Rename Worksheet in excel through code?
Example Sheet1 to MyWorksheet using a code in VB.Net
Reply With Quote
  #2  
Old 05-15-2007, 03:52 AM
Covey's Avatar
Creator of EliteSwitch
Ex-Moderator Visual Basic Programmers
 
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
Default Re: Rename Worksheet in excel through codes

the actual file name or the excel speadsheet. or rename one of the sheets inside that file?
__________________
EliteSwitch v4 Source Code - http://sythe.org/showthread.php?t=1214654
Reply With Quote
  #3  
Old 05-15-2007, 05:38 AM
WalangAlam
 
Posts: n/a
Default Re: Rename Worksheet in excel through codes

yes rename one of the sheets inside that file. We have only one sheet in the excel file and i want to rename it using code.
Reply With Quote
  #4  
Old 05-15-2007, 08:04 AM
Covey's Avatar
Creator of EliteSwitch
Ex-Moderator Visual Basic Programmers
 
Join Date: Sep 2005
Location: Fuckin' BAM!
Posts: 4,464
Default Re: Rename Worksheet in excel through codes

Quote:
Originally Posted by WalangAlam View Post
yes rename one of the sheets inside that file. We have only one sheet in the excel file and i want to rename it using code.
I don't think its possible unless Excel can handle "Macro Scripting" or you do something shitty like getting the handle of its window and using the mouse to click on it etc.
__________________
EliteSwitch v4 Source Code - http://sythe.org/showthread.php?t=1214654
Reply With Quote
  #5  
Old 05-15-2007, 03:12 PM
Active Member
 
Join Date: Mar 2007
Posts: 125
Post Re: Rename Worksheet in excel through codes

Here are two ways of doing this

OLD VB6 way and still works on .net

Code:
Dim xlApp As Object = CreateObject("Excel.Application")
Dim xlBook As Object = xlApp.Workbooks.Open("c:\Test.xls")
xlBook.Worksheets(1).Name = xlBook.Name 'or any name you want
xlBook.Close(1)
xlApp.Quit()
.net way (still using COM Excel object) i like this one better since you can do more with this

Code:
       Dim exc As New Application
        Dim workbooks As Workbooks = exc.Workbooks
        Dim workbook As Workbook = workbooks.Open("c:\Test.xls")
        Dim sheets As Sheets = workbook.Worksheets
        Dim worksheet As Worksheet = CType(sheets.Item(1), Worksheet)
        worksheet.Name = "WOWThis is Cool"
note for this last one you will need the follwing

add the follwing references to your project


add this import to your class file
Code:
Imports Microsoft.Office.Interop.Excel

Last edited by dodge : 05-15-2007 at 03:13 PM.
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 06:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1