View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
in-over-his-head-bill in-over-his-head-bill is offline
external usenet poster
 
Posts: 18
Default How do you name a new workbook in VBA

I am trying to create a new workbook out of vba. When I try to name it
something beside the default book1,book2, etc... I get a "can't assign to
read-only property" error. How do I name a new workbook?
My code follows with public variables savetofile and savetorange

Public Sub manageoutput_new()
Dim mywb As Workbook, myws As Worksheet

Set mywb = Workbooks.Add

'* problem line is next
mywb.Name = savetofile
mywb.Activate
Set myws = Worksheets.Add
myws.Name = savetorange


End Sub