Thread: Save As
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Save As

One way:

Option Explicit
Sub testme01()

Dim myName As String

With ActiveWorkbook
myName = .Name

myName = Application.Substitute(LCase(myName), ".xls", "") & _
"_" & Format(Now, "yyyy-mm-dd-hh-mm")


.SaveAs Filename:=.Path & "\" & myName

'.SaveCopyAs Filename:=.Path & "\" & myName
End With

End Sub

Take a look at .savecopyas in VBA's help. You'll see that it makes a backup of
the file without saving the current file--or changing its name. (It may be
useful--one day?)

Orf Bartrop wrote:

How would I go about saving a workbook to another name that contains the
date and time? Let's say the original file is called "Book." What I
would like to do is have a macro that saves "Book" as "Book-yy-mm-dd-hh-mm"
Any suggestions?


--

Dave Peterson