![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com