Can Date Automatically Appear in Document Name

G

Guest

I would like to be able to modify my normal template such that when I save my
documents as "document name" the document is saved as "document name"
2005-12-25.doc

Thus all of my saved documents would have the date built into the name. Is
it possible to have this automatically done without having to type the date
every time I save a document?
 
G

Graham Mayor

What's the point of this? Whenever you save a document, the file is date &
time stamped anyway. Switch Explorer to 'details' view and save yourself a
lot of programming grief.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?TWlrZQ==?=,
I would like to be able to modify my normal template such that when I save my
documents as "document name" the document is saved as "document name"
2005-12-25.doc

Thus all of my saved documents would have the date built into the name. Is
it possible to have this automatically done without having to type the date
every time I save a document?
It would certainly be possible. It would involve naming a macro FileSave, and
another FileSaveAs. If you want this to happen for all documents on your system,
create the procedures in your Normal.Dot template. For just certain documents,
create them in that template. Those macros could look like this

Sub FileSave()
Dim doc As Word.Document

Set doc = ActiveDocument
If doc.Saved = False And _
Left(doc.Name, Len("Document")) = "Document" Then
SaveFileWithDate
Else
doc.Save
End If
End Sub

Sub FileSaveAs()
SaveFileWithDate
End Sub

Your main macro, called by the other two, would need to display the Save As
dialog box, but not allow it to execute. Roughly, that code would look like
this:

Sub SaveFileWithDate()
Dim s As String

With Dialogs(wdDialogFileSaveAs)
If .Display <> 0 Then
s = .Name
s = Replace(s, ".doc", "")
ActiveDocument.SaveAs s & Format(Date, "yyyy-mm-dd") & ".doc"
End If
End With
End Sub

If you need more help with this, I suggest you follow up in a more appropriate
Word.VBA newsgroup.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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

Top