
Tips.Net > WordTips Home > Macros > Automatically Inserting Tomorrow's Date
Summary: Do you routinely need to work with tomorrow’s date? Why not create a template that automatically adds tomorrow’s date to any point in the document you want. This tip shows how easy this can be. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
Let's say that you work for a company and that your job is to prepare reports or press releases that will be distributed the next day. On every one of these documents you need to make sure that tomorrow's date appears. After doing this for a while, you may start searching about for a way to automatically insert tomorrow's date into a new document. It would be even better if this automatic feature could be included as part of a template. Thus, when you create a new document based on the template, it automatically has tomorrow's date in the proper place.
Your first inclination might be to simply change the system date that is on your computer. If you increase the system date by one day, then by being out of kilter with the rest of the world by one day, you can easily insert the date you need. While this would do the job, it will definitely affect all other uses of the date on that system, as well.
There is a relatively easy solution within Word, however. The following macro, when saved in the template using the name AutoNew, replaces a bookmark called MyDate with tomorrow's date. The cool thing about the macro is that it doesn't just insert a date at the beginning of the file, but gives you control over the exact placement anywhere within the file.
Sub AutoNew()
With ActiveDocument.Bookmarks("MyDate").Range
.InsertBefore Format(Date + 1, "dd mmmm yyyy")
End With
End Sub
The format in which the date appears can be modified by altering the "dd mmmm yyyy" string to achieve the desired format. More information on format strings is available in the online VBA documentation.
To use the macro, all you need to do is make sure that the template includes some text that is bookmarked using the name MyDate. Save the template, and then any new documents you create based on that template will automatically include tomorrow's date in place of the bookmark.
Tip #1312 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Great Idea! Uncover the many ways you can master the full potential of printing your documents. WordTips: Printing and Printers can help you get the most from both the printed page and your printer.
The real power behind Word's best documents lies in understanding styles and templates. Learn the key to more powerful document creation. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips