Add new workbook with new name

  • Thread starter Thread starter MarMo
  • Start date Start date
M

MarMo

Hi there ,
To add a new workbook with VBA the code is a follows :
Workbooks.add
This opens a new workbook with the default name book1.xls

Is there a way to alter the name when adding a new workbook ?
I'd like to add the name through my VBA code when adding a new book.

Thanks for any replies
MarMo
 
try this way:

Sub TestWA() Workbooks.Add
ActiveWorkbook.SaveAs "Test.xls"
End Sub

pls do rate
 
thanks guys ,
Thanks for the suggestions. I tried saving it ,and it works fine.
But it's not what i'm looking for. What i'm asking is propably not possible.

When Excel opens a new book it does not save the book in a normal way.
It opens a book with the default name "Book1.xls".
As i'm adding up to 6 new workbooks with VBA in an excel application , Excel
opens Book1.xls to Book6.xls
What i'd like to do is , when adding a new book to assign a name to the new
opened book without saving it directly.
It's probably a stupid idea , but i'd like to know if it's possible.
Maybe i should save the workbooks to some folder and let the user decide
what to do with it.

Any other suggestions are welcome.
MarMo
 
Hi MarMo,

You have to save it first!, but you can do that by a *.xlt or template
file
Or you only want to ActiveWindow caption look only by :

ActiveWindow.caption = "Mybook"

Thanks,

Halim

MarMo menuliskan:
 
Halim ,
This is exactly what i was looking for.
So i presume that whenever Excel opens a new book , it only changes the
caption ?
Thanks for this very much
MarMo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top