Solved

Rename excel sheet from Access

Posted on 2013-06-09
9
362 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 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

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

765 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