Solved

Rename excel sheet from Access

Posted on 2013-06-09
9
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 50

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 50

Expert Comment

by:Gustav Brock
ID: 39234382
You are welcome!

/gustav
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

735 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