How to Save with automatic filename plus today's date

Gary Drumm

Active Member
Joined
Feb 22, 2005
Messages
462
Is there a way to save a file and have it automatically put today's date in the file name?

Example: original File name = test.xls
desired file name = test072807.xls, or test.072807.xls, or test.07 28 07.xls

So, I open the file, do whatever, and then click save.
When I click save, it does one of the above, given that today is 7 28 07.

I tried to search for this topic, but search wasn't working well on my PC today.

Thanks,
Gary
 
Gary,

Unfortunately, I have not been able to duplicate the problem that you are running into.

Maybe try changing to this?
Now the workbook will save itself, then perform the save as when closed.... :unsure:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Save
Application.DisplayAlerts = False

Dim strMyDir As String
Dim strDate As String

strMyDir = "c:\My Documents\Blood Sugar\"
strDate = Format(Now, "mm-dd-yy")

If Dir(strMyDir, vbDirectory) = "" Then
    MkDir strMyDir
End If

ActiveWorkbook.SaveAs (strMyDir & "Blood Sugar " & strDate & ".xls")

Application.DisplayAlerts = True
End Sub
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top