Solved

Rename excel sheet from Access

Posted on 2013-06-09
9
359 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

803 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