Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default Code to add a workbook the rename it

Hi Excel users and experts

Excel 2002

From help I get the following to name a workbook. It errors out with a
yellow line. I tried the macro recorder but it give the file name and a
whole string of stuff I don't want using Save As.

Am I missing a menu item that will allow me to record a workbook name
change??? (The AutoFit is just part of the code to format a sheet)

Columns("A:K").Columns.AutoFit
Workbook.Names.Add Name:="The Newest"

Thanks,
Howard


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Code to add a workbook the rename it

What you got from the macro recorder is going to be closer to what you want.
You can not just change the name of a file. You need to save it. The first
time you save something it is by default a save as operation...

dim wbkNew as workbook

set wbknew = workbooks.add
with wbknew
.saveas "C:\Myfile.xls"
.close 'or whatever you want to do with then new book
end with
--
HTH...

Jim Thomlinson


"L. Howard Kittle" wrote:

Hi Excel users and experts

Excel 2002

From help I get the following to name a workbook. It errors out with a
yellow line. I tried the macro recorder but it give the file name and a
whole string of stuff I don't want using Save As.

Am I missing a menu item that will allow me to record a workbook name
change??? (The AutoFit is just part of the code to format a sheet)

Columns("A:K").Columns.AutoFit
Workbook.Names.Add Name:="The Newest"

Thanks,
Howard



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Code to add a workbook the rename it

This is from the VBA help file:

The Name property returns the workbook name. You cannot set the name by
using this property; if you need to change the name, use the SaveAs method to
save the workbook under a different name.

"L. Howard Kittle" wrote:

Hi Excel users and experts

Excel 2002

From help I get the following to name a workbook. It errors out with a
yellow line. I tried the macro recorder but it give the file name and a
whole string of stuff I don't want using Save As.

Am I missing a menu item that will allow me to record a workbook name
change??? (The AutoFit is just part of the code to format a sheet)

Columns("A:K").Columns.AutoFit
Workbook.Names.Add Name:="The Newest"

Thanks,
Howard



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default Code to add a workbook the rename it

Thanks Jim and JL, that sheds some light on it.

Regards,
Howard

"L. Howard Kittle" wrote in message
...
Hi Excel users and experts

Excel 2002

From help I get the following to name a workbook. It errors out with a
yellow line. I tried the macro recorder but it give the file name and a
whole string of stuff I don't want using Save As.

Am I missing a menu item that will allow me to record a workbook name
change??? (The AutoFit is just part of the code to format a sheet)

Columns("A:K").Columns.AutoFit
Workbook.Names.Add Name:="The Newest"

Thanks,
Howard



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a new workbook and rename the workbook? pokdbz Excel Discussion (Misc queries) 3 December 26th 07 03:37 PM
Rename worksheets of workbook - Error code [email protected] Excel Programming 1 July 21st 07 12:31 AM
Rename a new workbook Jan Eric Nilsson Excel Programming 2 July 17th 05 02:36 AM
How can I rename a Workbook? Mac Lingo[_2_] Excel Programming 2 April 23rd 05 09:24 PM
Rename a workbook! aiyer[_22_] Excel Programming 1 May 12th 04 05:12 PM


All times are GMT +1. The time now is 05:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"