How to copy a workbook
Oops! Missed the part about the code being in the Master and copying the
template;
myNames = Array(Name1, Name2, Name3....Namen)
myPath = ThisWorkbook.Path '<<<assumes same folder as master
For i = LBound(myNames) To UBound(myNames)
Workbooks("TEMPLATE.xls").SaveAs FileName:=myPath & "\" & myNames(i) &
".xls"
Next
If TEMPLATE is an object variable for a workbook then just TEMPLATE.SaveAs
etc.
"WLMPilot" wrote in message
...
Thanks. I apologize for not making this clearer. I will have a MASTER
workbook that is used by the boss. Inside the Master workbook will be a
commandbutton to execute a macro that will copy the TEMPLATE workbook and
rename it to match the employee(s) name.
There will be a list of all employees in the Master workbook that I will
read into an array to initially set everything up to match the current
employees. After that, I will have it worked out to copy the TEMPLATE for
each new employee.
Therefore, the code is actually in the MASTER workbook. I wanted to know
what the actual code that will copy the TEMPLATE and rename it (using a
variable that holds the employee's name) will be. I believe I will be
able
to add that addition code to read the names.
Thanks,
Les
"Mike H" wrote:
Hi,
This would go in your 'template' workbook.
This string
S = "aaa,bbb,ccc"
should be changed to your list of employees
Sub Sonic()
Dim V As Variant
Dim S As String
S = "aaa,bbb,ccc"
V = Split(S, ",")
For x = 0 To UBound(V)
ThisWorkbook.SaveAs Filename:=V(x)
Next x
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"WLMPilot" wrote:
I need to know how to copy a workbook in a macro (Excel 2002)
The filename of the workbook to be copied is "Template" (w/o quotes)
The new workbook will have the name of an employee, ie several
workbooks,
each having the name of an employee.
Variable: EMP = "John Doe"
Code needed to copy workbook TEMPLATE and rename to variable EMP.
Thanks,
Les
|