encoding Today's date

  • Thread starter Thread starter Pablo
  • Start date Start date
P

Pablo

I am trying to insert the current date into the name of a
file below is the code snippet I am working with.

ActiveWorkbook.SaveAs Filename:= _
"\\aussvprod\Marketing\Product Information\PM
Reports\1020 PM Reports\1020 Slater.xls" _

The 1020 represents the date 10/20, but it does not have
to be formatted, 1020.
 
Pablo,

ActiveWorkbook.SaveAs Filename:= _
"\\aussvprod\Marketing\Product Information\PM
Reports\" & Month(Date) & Day (Date) & " PM Reports\1020 Slater.xls" _
 
Hi

It's done with

Format$(Date, "mmdd")

returning 1020 as a string for a little while longer. Like:

Dim sD As String
sD = Format$(Date, "mmdd")
ActiveWorkbook.SaveAs Filename:= _
"\\aussvprod\Marketing\Product Information\PM" & _
"Reports\" & sD & " PM Reports\" & sD & "Slater.xls"

In this case you are assuming that a properly named folder for today is present. If not,
or if only maybe or only probably, use MkDir function to create it before saving the file.
 
? format(date,"mmdd")
1020

so:

sName = "\\aussvprod\Marketing\Product Information\PM Reports\"
sName = sName & format(date,"mmdd") & " PM Reports\"
sName = sName & format(date,"mmdd") & " Slater.xls"
ActiveWorkbook.SaveAs Filename:= sName
 
Back
Top