encoding Today's 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.
 
S

steve

Pablo,

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

Harald Staff

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.
 
T

Tom Ogilvy

? 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top