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

Saving Documents as Read-Only by Default

When you save your documents, you can specify that they be saved in a "read-only" format so that they cannot be changed ...

Discover More

Splitting Information into Rows

Got too much information in a single cell? Here's how you can use a macro to pull apart that information and put it into ...

Discover More

Converting Individual Endnotes and Footnotes

Word makes it easy to convert all your footnotes to endnotes and vice versa. You may want to only convert a couple of ...

Discover More

Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!

More WordTips (ribbon)

Determining If a Number is Odd or Even

Need to know if a number in a macro is odd or even? It's easy to figure out with the simple calculation shown in this tip.

Discover More

Determining if Overtype Mode is Active

Your macro may need to determine if the user has overtype mode turned on. You can find out the overtype status easily by ...

Discover More

Aligning a Paragraph in a Macro

If you are applying formatting from within a macro, you may want to change the alignment of various paragraphs. Here's ...

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 3 + 7?

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.