VBA & Macro Problems

How to Add Six Months to a Date Picker in Word Using VBA

John WilsonJohn Wilson Nov 3, 2026 869 views

Question details

The user needs a way to automatically calculate and display a date that is exactly six months after a date selected in a date picker content control.

How to Add Six Months to a Date Picker Value in Word VBA
Product
Microsoft Word
Device & OS
not provided
Scenario
Creating a dynamic Word document or form where multiple output fields need to automatically update based on a single selected date.
Observed behavior
Target output controls dynamically display the calculated future date automatically when the user selects a date and exits the date picker.
Before you start

Ensure that the Developer tab is enabled in your Word ribbon, as you will need it to insert Content Controls and access the Visual Basic Editor.

Solution 1Recommended

Use a Content Control Exit Macro to Calculate the Future Date

This is the most reliable method for automatically updating other fields as soon as the user selects a date and exits the date picker.

By utilizing the Document_ContentControlOnExit event in VBA, you can instruct Word to perform a calculation immediately after the user interacts with the date picker. The script extracts the chosen date, adds six months using the DateAdd function, and populates the results into designated text controls.

1
Set Up Content Controls

On the Developer tab, insert a Date Picker Content Control and click Properties to set its Title to 'StartDate'. Then, insert Plain Text Content Controls where the future dates should appear and set their Titles to 'EndDate'.

2
Access the VBA Editor

Press Alt + F11 to open the Visual Basic Editor. In the Project pane on the left side, double-click on 'ThisDocument' to open the code window for your active document.

3
Insert the Exit Macro

Create a Private Sub Document_ContentControlOnExit macro. Check if the control title is 'StartDate', use DateAdd("m", 6, CDate(.Range.Text)) to calculate the future date, and use a For loop to update the text of all controls titled 'EndDate'.

4
Save as a Macro-Enabled Document

Navigate to File > Save As, and choose 'Word Macro-Enabled Document (*.docm)' from the format dropdown. Standard .docx files cannot save VBA code, so this format is strictly required.

Use a Content Control Exit Macro to Calculate the Future Date
Customizing the Date Format: You can customize the output format by applying the Format function in your VBA code, such as Format(Dt, "D MMM YYYY"), which outputs dates like '15 Jan 2024'.
Free Microsoft Office alternative

Discover WPS Office for Seamless Document Management

Struggling with complex Microsoft Word VBA macros or looking for a more accessible solution? WPS Office provides a free, lightweight, and highly compatible alternative that makes daily document editing, formatting, and template management a breeze.

  1. 1. Download and Install: Visit the official WPS Office website to download the free installer for your operating system.
  2. 2. Open Your Documents: Open your existing .docx and .docm files directly in WPS Writer without losing any of your formatting.
  3. 3. Edit and Save: Enjoy a familiar interface to continue your work efficiently and save your work in standard Office formats.
Completely free and lightweight office suite for daily document workflowsExcellent compatibility with Microsoft Word files, including .docx and macro-enabled .docm formatsRobust document form capabilities and intuitive tools without steep learning curvesFamiliar user interface ensuring a seamless migration from Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my VBA macro triggering when I pick a date?

The macro relies on the Document_ContentControlOnExit event. It only triggers after you select the date and click outside the date picker (exiting the control). Also, ensure your controls have the exact Title ('StartDate') specified in the code, as VBA is case-sensitive.

Can I add years instead of months using the DateAdd function?

Yes. In the DateAdd function, simply change the interval parameter from 'm' (months) to 'yyyy' (years). For example, DateAdd("yyyy", 1, date) successfully adds one year to the selected date.

Why do I need to save the document as a DOCM file?

Standard Word documents (.docx) are stripped of executable code for security reasons. Saving as a Word Macro-Enabled Document (.docm) ensures that your VBA script is retained the next time you open the file.

Is it possible to calculate future dates without using VBA?

Yes, but it requires complex nested field codes (like formula fields using the DATE function) which are notoriously difficult to set up and maintain. Using VBA provides a much cleaner and more reliable solution when working with content controls.