Including a Date-Based Special Notice in a Letter

Written by Allen Wyatt (last updated June 27, 2026)

Jennifer has a form letter that she sends out periodically. If the date that she prints the letter is within the last week of the month, she has a special notice she would like included near the beginning of the letter. If it is not the last week of the month, the notice should not appear. Jennifer wonders if there is a way to include the notice automatically based on the date.

The easiest way to accomplish this task is by combining a macro, typically run when the document is first opened, to set a document variable. Then, you can use a field to evaluate the document variable and insert a notice that is stored in a Building Block.

The first task for Jennifer is to create her special message and store it in a Building Block called something catchy, such as MonthEndNotice. The notice can contain just about anything that should be displayed during the last week of the month.

Next, a simple macro needs to be created that sets the document variable. Here's an example:

Sub IncludeNotice()
    Dim d As Date
    Dim LastDay As Date

    d = Date
    LastDay = DateSerial(Year(d), Month(d) + 1, 0)

    If LastDay - d < 7 Then
        ActiveDocument.Variables("ShowNotice").Value = "1"
    Else
        ActiveDocument.Variables("ShowNotice").Value = "0"
    End If

    ActiveDocument.Fields.Update
End Sub

Again, this macro should be run each time the document is opened. It determines today's date (in the d variable) and then calculates the last day of the month. If d is within the last week of the month, then the ShowNotice variable is set to 1, otherwise to 0.

Now, within the document, you can use the following compound field where you want the notice, if appropriate, to appear:

{ IF { DOCVARIABLE ShowNotice } = "1" { AUTOTEXT "MonthEndNotice" } "" }

Each set of braces in this field should be entered using the Ctrl+F9 shortcut. The DOCVARIABLE field returns whatever is in the ShowNotice document variable, a value set by the macro. If it is equal to 1, then the IF field executes the AUTOTEXT field, which returns the content of the MonthEndNotice Building Block. If ShowNotice is any value other than 1, then an empty string ("") is returned.

The last line of the macro updates fields in the document, but you may want to update them manually before actually printing your document. The desired special notice should appear only if the current date is within the last week of the month.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9810) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Locking Worksheet Names

Want to stop other people from changing the names of your worksheets? You can provide the desired safeguard by using the ...

Discover More

Status Bar Summing No Longer Available

When you select a range of cells, Excel normally displays the sum of those selected cells on the status bar. If the sum ...

Discover More

Inserting the Current Time with Seconds

If you need to insert the current time, with seconds, then you'll need the macro discussed in this tip. It's easy to use ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!

More WordTips (ribbon)

Understanding Document Variables

When working with macros, you may want to create a variable that will remain constant from one instance of the macro to ...

Discover More

Determining the Upper Bounds of an Array

When working with variables in a macro, you may need to know the upper boundary dimension for an array. This can be ...

Discover More

Creating a Document Font List

If you want a list of all the fonts used in a document, the answer isn't as simple as you may think. This tip uses macros ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one more than 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.