Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Workbook name

guys,
In VBA I am adding a new workbook to an XL application object. I would
like to name the new workbook either at the time it is added to the
workbooks collection or after it is added however, even though the VBA
help file says the "Name" property of a Workbook "returns or sets the
name of the object", it appears to be read-only.

For reference a snippet of my code is:
Xl.Workbooks.Add
BookNum = Xl.Workbooks.Count
Xl.Workbooks(BookNum).Name = "bob"

The last line fails with a run-time error - wrong number of arguments or
invalid property assignment.

Is there a way to name a new workbook or rename an existing one other
than doing so via Save As?

John
Project MVP
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Workbook name

Hi John,

A workbook is named as part of the save or saveas operation.

Try:

XL.Workbooks.Add
ActiveWorkbook.SaveAs "Bob", xlWorkbookNormal

---
Regards,
Norman



"John" wrote in message
...
guys,
In VBA I am adding a new workbook to an XL application object. I would
like to name the new workbook either at the time it is added to the
workbooks collection or after it is added however, even though the VBA
help file says the "Name" property of a Workbook "returns or sets the
name of the object", it appears to be read-only.

For reference a snippet of my code is:
Xl.Workbooks.Add
BookNum = Xl.Workbooks.Count
Xl.Workbooks(BookNum).Name = "bob"

The last line fails with a run-time error - wrong number of arguments or
invalid property assignment.

Is there a way to name a new workbook or rename an existing one other
than doing so via Save As?

John
Project MVP



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Workbook name

In article ,
"Norman Jones" wrote:

Hi John,

A workbook is named as part of the save or saveas operation.

Try:

XL.Workbooks.Add
ActiveWorkbook.SaveAs "Bob", xlWorkbookNormal

---
Regards,
Norman



Norman,
Thanks. I was hoping I could name the new workbook when it was created,
(as is possible with a Worksheet), but I essentially ended up using the
suggestion you gave.

John
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
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
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
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 11:12 AM.

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

About Us

"It's about Microsoft Excel"