Solved

Rename excel sheet from Access

Posted on 2013-06-09
9
355 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
 

Author Comment

by:shieldsco
ID: 39233556
Just the first sheet from a button in access
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 26

Expert Comment

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

Author Comment

by:shieldsco
ID: 39233580
2010
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 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 49

Expert Comment

by:Gustav Brock
ID: 39234382
You are welcome!

/gustav
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now