Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Save Name to Include System date and time

Status
Not open for further replies.

silknowles

Technical User
Aug 28, 2001
5
US
I'm trying to create a new name each time I save a file by including the system date and time in the name. How do I do this in VBA code?

Susan
 
I figured out the solution! I'm putting it here in case others have the same puzzling situation:

Dim SendPath, NameFile, SaveAsFile
'
Application.DisplayAlerts = False
'
SendPath = "\\ServerName\DirectoryName\Store01\"
NameFile = "RegularStore01_"
'
SaveAsFile = Application.Text(Now(), "yyyy mm d hh mm AM/PM")
'
NameFile = NameFile & SaveAsFile & ".csv"
ChDir SendPath
ActiveWorkbook.SaveAs Filename:=SendPath & NameFile, _
FileFormat:=xlCSV, CreateBackup:=False
'
Application.DisplayAlerts = True


This results in a file saved as "RegularStore01_2001 10 25 02 45 PM" when the system date was October 25, 2001 2:45 PM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top