Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can't name new workbook

Is it possible to name a new workbook in VBA? I keep trying to, and get a
message that workbook.name is ready-only. If it's read-only, does that mean
you can't name a workbook in VBA? I thought I had a long time ago, but I
can't find the code in my library. Confused.

wbNew.name = "Ted" <---Compile error. Can't assign to read-only property.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Can't name new workbook

You need to save it to give it a new name. Use

wbNew.SaveAs (Filename)

"salgud" wrote:

Is it possible to name a new workbook in VBA? I keep trying to, and get a
message that workbook.name is ready-only. If it's read-only, does that mean
you can't name a workbook in VBA? I thought I had a long time ago, but I
can't find the code in my library. Confused.

wbNew.name = "Ted" <---Compile error. Can't assign to read-only property.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can't name new workbook

On Mon, 13 Apr 2009 13:09:01 -0700, Barb Reinhardt wrote:

You need to save it to give it a new name. Use

wbNew.SaveAs (Filename)

"salgud" wrote:

Is it possible to name a new workbook in VBA? I keep trying to, and get a
message that workbook.name is ready-only. If it's read-only, does that mean
you can't name a workbook in VBA? I thought I had a long time ago, but I
can't find the code in my library. Confused.

wbNew.name = "Ted" <---Compile error. Can't assign to read-only property.


Thanks!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Can't name new workbook

Yep, that is what the help files say. The workbook's name is its filename on
the hard disk, so you have to execute code that will change its name there.
If the workbook is open, you should be able to use the SaveAs method like
Barb posted. If it is not open, the you can rename the file on the disk
using VB's Name..As statement. For example...

Name "C:\Users\Rick\Documents\NewBook.xls" As
"C:\Users\Rick\Documents\Ted.xls"

assuming its current name is "NewBook".

--
Rick (MVP - Excel)


"salgud" wrote in message
.. .
Is it possible to name a new workbook in VBA? I keep trying to, and get a
message that workbook.name is ready-only. If it's read-only, does that
mean
you can't name a workbook in VBA? I thought I had a long time ago, but I
can't find the code in my library. Confused.

wbNew.name = "Ted" <---Compile error. Can't assign to read-only property.


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
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 07:34 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"