View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Macro assigned to a button

Dim NewName as string
dim NewNamePfx as string
dim iCtr as long

newnamePfx = "C:\whateveryouwant\filename"

in some kind of loop

for ictr = 1 to 100
newname = newnamepfx & format(now, "yyyymmdd_hhmmss") & ".xls"
activeworkbook.savecopyas newname
next ictr

This saves 100 copies and includes the date/time in the filename.


Sadcrab wrote:

Thanks Dave,

What I would like to do is save the same workbook (with different data)
several times giving a new name to each saved workbook when moved. At the
moment using this macro will overwrite the last saved workbook and not give
me an option to save as and give a different name.

"Dave Peterson" wrote:

I think Don was just showing a sample so you could see how to use the Name
statement.

If you want to save an open workbook as a new name and then delete the original
workbook, you could do something like this (with absolutely no checks at all!):

Option Explicit
Sub testme()
Dim OldName As String
Dim NewName As String

NewName = "C:\changethistowhatyouneed\filename.xls"

With ActiveWorkbook 'or ThisWorkbook????
OldName = .FullName
.SaveAs Filename:=NewName, FileFormat:=xlWorkbookNormal
End With

Kill OldName

End Sub





Sadcrab wrote:

"Don Guillett" wrote:

maybe this simple idea will help?
Sub movefile()
OldName = "C:\oldfolder\oldname.xls"
NewName = "C:\newfolder\newname.xls"
Name OldName As NewName
End Sub


--
Thanks Don but I can't get it to work. I get a runtime error 53 File not
found more help on this please. Thanks


--

Dave Peterson


--

Dave Peterson