Automatically saving current date in the filename

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

This might be an odd request. I have multiple files that I
update periodically. I would like to be able to have it so
that when I save the file it puts the save date in the
filename. Currently I have to save the document, close it,
and change the filename manually to put the current date
in it. (ie. SH01-12-05-03) If I make some changes to the
file today I would like it to automatically change the
filename to SH01-12-18-03 The reason for this is so that I
can quickly look at some files and see when they have been
updated. I have no idea how to do this, or if its even
possible. Any help would be appreciated.
Thanks,
Kevin
(e-mail address removed)
 
This is possible, but it's fairly messy coding. Are you aware that if you
display a list of files in Windows Explorer (which includes any file > open
dialog) you can display the date last modified, and you can sort the list by
that value? Learning to use this feature will be much quicker than writing
code to do what you ask. And it has the advantage that you can use the file
name for the better purpose of identifying the content of the document.

Saving the file under a specific name -- eg including the date and time --
is easy enough; but renaming the file every time you save it is rather more
fraught. Certainly do-able: write macros called FileSave and
FileSaveDefault -- these will run in place of the built-in commands; but it
introduces an unreliability and a maintenance task into your Word set-up
that you are likely to get sick of very quickly.
 
You might want to change your dates to put the year first. That way they
will show up in folders in order by year, month, day instead of sorted by
month, day then year.

Last year Astrid posted the following in the word97vba newsgroup that may
help get you started:

Here's some code that sets the name of the document with the current date
behind it. Note that it doesn't test if the name of the current document has
a date already (that would be the case if you run the macro multiple times
for the same document)
------------------------------------------
Dim sNewTitle As String

sNewTitle = "Invoice " & _
Format(Date, "M dd yy")

With Dialogs(wdDialogFileSummaryInfo)
.Title = sNewTitle
.Execute
End With
With Dialogs(wdDialogFileSaveAs)
If Len(ActiveDocument.Path) > 0 Then
'Document was saved before
'add name for save as dialog
.Name = ActiveDocument.Name & _
" " & Format(Date, "M dd yy")
End If
.Show
End With
------------------------------------------


--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
Back
Top