Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Rename excel sheet from Access

Posted on 2013-06-09
9
Medium Priority
?
370 Views
Last Modified: 2013-06-10
I need to rename an Excel sheet from a button in Access. Any thoughts. Thanks
0
Comment
Question by:shieldsco
  • 4
  • 3
  • 2
9 Comments
 
LVL 26

Expert Comment

by:jerryb30
ID: 39233547
Name filepath\filename as newfilename
0
 

Author Comment

by:shieldsco
ID: 39233551
I need to rename the sheet not the file
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 39233554
Ah, missed that.
OK. All worksheets? Just the 1st (2nd, 3rd,) etc? Do they already have names other than default?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shieldsco
ID: 39233556
Just the first sheet from a button in access
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 39233576
Access and excel versions?
0
 

Author Comment

by:shieldsco
ID: 39233580
2010
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 39233899
Establish a Reference to Microsoft Excel 14.0 Object Libraries (menu Tools, References.

Run code like this:
Public Sub RenameWorkSheet()

    Dim xls     As Excel.Application
    Dim wkb     As Excel.Workbook
    Dim wks     As Excel.Worksheet
    
    Set xls = New Excel.Application
    Set wkb = xls.Workbooks.Open("c:\test\workbook1.xlsx")
    Set wks = wkb.Worksheets(1)
    
    wks.Name = "My New Name"
    wkb.Close True
    
    Set wks = Nothing
    Set wkb = Nothing
    
    xls.Quit
    
    Set xls = Nothing

End Sub

Open in new window

/gustav
0
 

Author Closing Comment

by:shieldsco
ID: 39234358
Good Job -- Thanks
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 39234382
You are welcome!

/gustav
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question