Hi ?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 :-)