PC Review


Reply
Thread Tools Rate Thread

Can't name new workbook

 
 
salgud
Guest
Posts: n/a
 
      13th Apr 2009
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 With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      13th Apr 2009
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.
>

 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      13th Apr 2009
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!
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      13th Apr 2009
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" <(E-Mail Removed)> wrote in message
news:fnf3s07t5lte$.1kkb0ccnuzs3a$.(E-Mail Removed)...
> 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 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
Possible to remove Workbook window title bar? Or other ways toarrange multiple workbook windows. minimaster Microsoft Excel Programming 4 15th Sep 2009 11:47 AM
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 Microsoft Excel Programming 1 1st Apr 2006 08:48 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Microsoft Excel Programming 9 25th Jul 2005 12:44 PM
Workbook.XLS worked fine. Now I installed workbook.XLT and both open very slowly in XL97 Marvin Hlavac Microsoft Excel Worksheet Functions 0 2nd Feb 2004 11:26 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Microsoft Excel Programming 1 24th Jul 2003 11:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:02 AM.