View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Need help with my code!

Here's what I came up with. This takes the active open workbook and saves
it 10 times with the same name plus an incremented number into the same
location.

Sub Foo_ManySave()

Dim objWkbk As Workbook
Dim strFPath As String
Dim strFName As String
Dim x As Long

Set objWkbk = ActiveWorkbook
strFPath = "C:\Documents and Settings\UserName\Desktop\New Folder"

For x = 1 To 10
strFName = strFPath & "\NewBook" & x & ".xls"
objWkbk.SaveAs strFName
Set objWkbk = ActiveWorkbook
Next x

End Sub

You will, of course, have to adjust the str variables to suit your own
parameters.
Ed

"smonczka" wrote in message
oups.com...
I have to duplicate a file about 1500 times with unique names. I am
trying to write a macro that will automatically save the file as
excel(X).xls where (X) is auto generated for as many times as I need.

I am new to basic but what I have cobbled together from different posts
is ...

Dim X As Long
Dim sFilename As String
For X = 1 To 1500
With ActiveWorkbook.(X)
sFilename = "http://intranet/deptSales/excel" & CStr(X) & ".xls"
ActiveWorkbook.SaveAs
End With
Next

If someone wouldn't mind telling me what have I got wrong?

Thanks for the help,
Steve