Saving Excel File with Name and Date Details

July 20, 2009 by vba excel
Filed under: Excel Tips 
Sponsor

Excel Tips Saving Excel File with Name and Date Details [Q]
I need excel tips to save Microsoft excel file I am working on (template) with the name of
the file and the date?

ex. “filename - 2008-10-29.xls”

also, if the name is duplicated, add a number to the end numerically

ex. “filename - 2008-10-29-01.xls”

Excel Tips Saving Excel File with Name and Date Details [A]

You can follow this excel tips to creates microsoft excel files in the
following format if already in the same path

filename - 2008-10-29.xls
filename - 2008-10-29(1).xls
filename - 2008-10-29(2).xls

etc…..

Dim myPath As String, myFile As String, myExt As String, mySerial As
String

mySerial = “”
myPath = “C:\Test\”
myFile = “filename” & ” - ” & Format(Date,”YYYY-MM-DD”)
myExt = “.xls”

‘ create output using sequence 1 to n if file already exists
If Len(Dir(myPath & myFile & mySerial & myExt)) > 0 Then

Do While Len(Dir(myPath & myFile & mySerial & myExt)) > 0
mySerial = “(” & Val(Mid(mySerial, 2)) + 1 & “)”
Loop

End If

ActiveWorkbook.SaveAs Filename:=myPath & myFile & mySerial & myExt

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Incoming excel search terms

excel file save date formula,save excel file with date,excel file save date,name of day excel date 2008,excel file date,excel file name,excel save date,save excel as date,append date to filename in excel macro,dim mypath as string myfile as string myext as string myserial as string,excel file details,excel file name with date,excel how to automatically save a file with date in name,excel save date formula,excel save file with date,excel vba file date,excel vba save file with date,save file date time seconds vba,vba open filename previous day date,,add time to filename when saving file,auto append filename excel with date,automatic date excel file name,automatic naming of excel files,automatically include date in excel file name,date created excel,details about a file in excel,details of excel sheet,excel date created,excel date of file,excel file date function,excel macro auto save different filename,excel macro to add date to filename,excel macros save as days date,excel save filename date,excel thisworkbook saveas mypath & myfile,excel vba add date time to filename,excel vba auto saveas filename date,excel vba filename date,excel vba saving a file as the name in a cell,formula for automatic date in excel,how to add the date to the name of an excel file when saving,how to put a date in excel file name,how to save a excel file using a filename based on date?,naming excel files,save an excel file under an automatic name,save file previous business day excel macro,saving a spreadsheet and appending the date to the filename,saving excel files,saving excel files with date



Related Excel Tips

Comments

Have another excel answer or questions for this problem ?
Feel free to post it here..