PC Review


Reply
Thread Tools Rate Thread

Code to add a workbook the rename it

 
 
L. Howard Kittle
Guest
Posts: n/a
 
      21st Feb 2008
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 With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      21st Feb 2008
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
>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      21st Feb 2008
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
>
>
>

 
Reply With Quote
 
L. Howard Kittle
Guest
Posts: n/a
 
      22nd Feb 2008
Thanks Jim and JL, that sheds some light on it.

Regards,
Howard

"L. Howard Kittle" <(E-Mail Removed)> wrote in message
news:8I-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a new workbook and rename the workbook? pokdbz Microsoft Excel Misc 3 26th Dec 2007 03:37 PM
Rename worksheets of workbook - Error code transferxxx@gmail.com Microsoft Excel Programming 1 21st Jul 2007 12:31 AM
Rename a new workbook Jan Eric Nilsson Microsoft Excel Programming 2 17th Jul 2005 02:36 AM
Rename a Workbook?? Don Microsoft Excel Worksheet Functions 4 19th Sep 2004 01:50 AM
Rename a workbook! aiyer Microsoft Excel Programming 1 12th May 2004 05:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:11 PM.