Written by Allen Wyatt (last updated June 26, 2018)
This tip applies to Word 97, 2000, 2002, and 2003
Michelle is a solo lawyer trying to develop a paperless office. One important factor is a document naming convention to help her organize and locate documents. Michelle would like to save all documents starting with the date YYYY_MM_DD to which she would add relevant client information. She wonders if there is a way to create a default for Word so that when she saves a new document, it automatically starts with the current date.
There are a few approaches you can take to handle this problem. Most of the solutions involve using a macro in one way or another. Perhaps the easiest macro-based approach is to make some modifications to the FileSaveAs command. This is the command that Word executes whenever you choose Save As (pressing F12 is the easiest way to do this) or whenever you click the Save button on the toolbar with a brand new document.
Public Sub FileSaveAs() Dim dlgSave As Dialog Set dlgSave = Dialogs(wdDialogFileSaveAs) With dlgSave .Name = Format(Date, "yyyy_mm_dd ") .Show End With End Sub
This macro is quite simple in concept: It simply puts the current date (in the desired format) into the Save dialog box and then shows the dialog box. In this way, the person can then add whatever "relevant client information" is desired after that date.
Another approach to put the current date into the Save As dialog box is to rely on the fact that Word, by default, uses the contents of the Title field in the document properties as the default filename. You can use fields to update the contents of the Title field. This means that you can follow these general steps:
Public Sub AutoNew() Application.ScreenUpdating = False ActiveDocument.Bookmarks("infotitle").Range.Fields.Update ActiveDocument.Bookmarks("infotitle").Range.Delete Application.ScreenUpdating = True End Sub
Remember that in perform step 2, the way you insert field braces is to press Ctrl+F9. The field (which is updated in the AutoNew macro) fetches the current date, in the format specified, and places it into the Title field of the document properties. The macro, after updating the field (and thereby setting the Title field), then deletes the field from the document itself.
The result is that when someone goes to save the document for the first time, Word grabs the contents of the Title field and uses it as the suggested filename for the document. The user can then add whatever "relevant client information" is desired after the date.
Additional thoughts on this topic of setting a standard file name can be found at this tip:
http://word.tips.net/T003531
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11617) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Setting a Document Naming Convention.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Hidden text is a great boon if you want to make sure something doesn't show up on the screen or on a printout. If you ...
Discover MoreWant to add one document to another document? You can do it by adding links, described in this tip.
Discover MoreNeed to force users to save their work? It may be as simple as implementing a couple of macros that get a bit more ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-01-08 19:06:19
I am definitely not a programmer but was able to recreate the above macro in my Word document, and it worked just fine. Thank you very much. But now, is there a way to add some of the document properties to your code line, ".Name = Format(Date, "yyyy_mm_dd ")", such as the revision number (in Statics) or any of the custom properties?
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments