Word for Windows Macro to Insert Specified Dates

Last reviewed: July 30, 1997
Article ID: Q71343
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

In Word, you can use a macro to have the date inserted be a number of days before or after today's date.

More Information

As an example, to insert a date that is seven days after today's date, you would insert the following in the macro editor depending on the platform used:

Word 6.0 for Windows NT

Sub MAIN
a$ = GetPrivateProfileString$("HKEY_CURRENT_USER\software\Microsoft\Word\6.0\Opt ions", "DateFormat", "") SetPrivateProfileString "HKEY_CURRENT_USER\software\Microsoft\Word\6.0\Options", "DateFormat", "MMMM dddd, yyyy", "" Insert Date$(Today() + 7) SetPrivateProfileString "HKEY_CURRENT_USER\software\Microsoft\Word\6.0\Options", "DateFormat", a$, ""
End Sub

Word 6.0 for Windows

Sub MAIN
a$ = GetPrivateProfileString$("Microsoft Word", "DateFormat", "Winword6.Ini") SetPrivateProfileString "Microsoft Word", "DateFormat", "MMMM d,yyyy", "Winword6.Ini" Insert Date$(Today() + 7) SetPrivateProfileString "Microsoft Word", "DateFormat", a$, "Winword6.Ini"
End Sub

Word 6.0 for Macintosh

Sub MAIN
a$ = GetPrivateProfileString$("Microsoft Word", "DateFormat", "Word Settings (6)") SetPrivateProfileString "Microsoft Word", "DateFormat", "MMMM d,yyyy", "Winword6.Ini" Insert Date$(Today() + 7) SetPrivateProfileString "Microsoft Word", "DateFormat", a$, "Word Settings (6)"
End Sub


KBCategory:
KBSubcategory:
Additional query words: future previous yesterday's
.END:
Version : 6.0 6.0a 6.0c 6.01
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.