using the now() function with saveas in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is these some way I can incorporate the now() function with the saveas function in a macro so that the file name is appended or replaced with the current date?
any help would be appreciated.
 
Try this Randy

Dim strdate As String
strdate = Format(Now, "mm-dd-yy")
ActiveWorkbook.SaveAs Filename:="C:\" & strdate & ".xls"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




Randy Welker said:
Is these some way I can incorporate the now() function with the saveas function in a macro so that the file name is appended
or replaced with the current date?
 
Randy,

Try something like

Activeworkbook.Saveas Filename:="C:\MyFiles\TestFile" & Format(Date,"dd
mmm yyyy") & ".xls"

if you want just the date, or

ActiveWorkbook.SaveAs Filename:="C:\MyFiles\TestFile" & Format(Time, "dd
mmm yyyy hh:mm:ss") & ".xls"

if you want the time as well
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Randy Welker said:
Is these some way I can incorporate the now() function with the saveas
function in a macro so that the file name is appended or replaced with the
current date?
 
Back
Top