View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Need your hep: Creating new workbooks and name it based on a l

After seeing the reply by Per Jessen I am now wondering if your template is
actually a normal workbook or a template file. If it is a template file then
Per's answer is what you will want. However, if it is a normal workbook then
try the following.

Create a new workbook and copy the following code.

Note the comments. I have created a variable for both the original workbook
and another for the multiple copies in case you want the copies in a folder
of their own. If both in the one folder then just set them both the same.

Also don't know what version of Excel you are using so have set macro to run
with Excel 97-2003 and have a commented out line of code for Excel 2007 in
case you need that.

Sub MakeMultiCopies()

Dim strTemplatePath As String
Dim strSavePath As String
Dim rngFileList As Range
Dim rngFileName As Range

'Edit following line to match your path for Template file
strTemplatePath = "C:\Users\\Documents\Excel\Template\"

'Edit following line to match your path for saving new workbooks
strSavePath = "C:\Users\\Documents\Excel\Multi Copies\"

With Sheets("Sheet1")
Set rngFileList = .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 1).End(xlUp))
End With

For Each rngFileName In rngFileList

'Edit following to match your Filename.
Workbooks.Open Filename:= _
strTemplatePath & "My Template.xls"

'Use following code to Save in XL97-2003 format
ActiveWorkbook.SaveAs Filename:= _
strSavePath & rngFileName.Value & ".xls", _
FileFormat:=xlNormal, CreateBackup:=False

'Substitute following code to save in XL2007 format
'ActiveWorkbook.SaveAs Filename:= _
strSavePath & rngFileName.Value & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

ActiveWindow.Close

Next rngFileName

End Sub

--
Regards,

OssieMac