
Tips.Net > WordTips Home > Macros > WordBasic Examples > Calculated Dates with WordBasic
Summary: Wanna do date math? Here's how to do it in WordBasic. (This tip works with Microsoft Word 6, and Word 95.)
You may wonder if there is a quick way to put a calculated date into a letter created in Word. For instance, you may want to send out mail-merged letters with a date that is 30 days after the date on which the letters were created.
Unfortunately, there is no native way to do this in Word. For instance, there is no field code you can use to insert a calculated date. If you are using Excel or Access as your data source for the mail merge, the simplest solution may be to just add a field in the data source that shows the calculated date. (It is very easy to do this in both Excel and Access.) The data source field can then be placed in the mail-merge document and everything is set.
If you want to stick with Word and cannot modify the data source (perhaps someone else supplies it), then you can use a macro to insert the future date. The following WordBasic macro will do the trick:
Sub MAIN
Insert Date$(Today() + 30)
End Sub
This macro determines today's date, adds 30 days to it, formats it according to the default formatting set up in Word, and inserts it into the document. If you assign this macro to a shortcut key, you can quickly insert your future date whenever you want.
Tip #809 applies to Microsoft Word versions: 6 95
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful "wildcard searches" available in Word.
Check out WordTips: Find and Replace today!
It doesn't matter if you are a beginner or expert, the WordTips archives are the fastest way to improved productivity. (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