Document Editing Problems

How to Add Current Date and Time to Word Content Controls

Elise WilliamsElise Williams Nov 3, 2026 869 views

Question details

The user wants a date picker content control to automatically insert both the current date and time when clicked, and needs to resolve an 'Ambiguous name detected' VBA compile error.

How to Add Current Date and Time to Word Content Controls
Product
Microsoft Word
Device & OS
not provided
Scenario
Creating an interactive document (like a Bingo card) where clicking a box must log the exact current time instead of defaulting to 12:00 AM.
Observed behavior
The date picker defaults to 12:00 AM instead of the current time, and a compile error 'Ambiguous name detected: Document_ContentControlOnEnter' prevents the VBA macro from running.
Before you start

Ensure you have the Developer tab enabled in your Word ribbon and make a backup copy of your document before editing VBA macros.

Solution 1Recommended

Configure Content Control and Fix the VBA Macro

Set up a Date Picker Content Control with the correct format, remove duplicate VBA event procedures causing the compile error, and apply the macro code to capture the exact time.

By default, standard Date Picker controls do not capture the exact time, resetting it to 12:00 AM. Using a VBA event procedure allows you to dynamically populate the control with the current date and time using the 'Now' function.

The compile error 'Ambiguous name detected' occurs when multiple procedures share the exact same name within the module. Removing the duplicate code will restore macro functionality.

1
Enable the Developer Tab

If you cannot see the Developer tab, go to Word Options > Customize Ribbon, check the box next to 'Developer', and click OK.

2
Insert and Format Date Picker

Navigate to the Developer tab, click the 'Date Picker Content Control' icon to insert it. Then, click 'Properties' in the Developer ribbon and choose a format from 'Display the date like this' that includes both date and time.

3
Open the VBA Editor

Press Alt+F11 on your keyboard to open the Visual Basic for Applications (VBA) editor. In the Project Explorer pane on the left, double-click 'ThisDocument'.

4
Delete Duplicate Procedures

Scan the code window for multiple instances of 'Private Sub Document_ContentControlOnEnter'. Delete the duplicates so that only one procedure with this name remains, which fixes the 'Ambiguous name detected' error.

5
Update the Procedure

Ensure your single 'Document_ContentControlOnEnter' procedure is programmed to insert the 'Now' function when the control still displays its placeholder text.

6
Save as a Macro-Enabled Document

Go to File > Save As and change the file type to 'Word Macro-Enabled Document (*.docm)' or 'Word Macro-Enabled Template (*.dotm)'. Macros will not run if saved as a standard .docx file.

Configure Content Control and Fix the VBA Macro
Avoid Typing Errors: Typing VBA code manually is error-prone. It is recommended to copy and paste your verified VBA code directly into the 'ThisDocument' module, ensuring it is not accidentally placed in a standard module.
Free Microsoft Office alternative

Try WPS Office for a Seamless Document Experience

If you frequently struggle with complex VBA macros, compile errors, or rigid formatting in Microsoft Word, WPS Office provides a lightweight, highly compatible, and user-friendly alternative. It handles professional document editing with ease while remaining free and accessible.

Free and lightweight office suiteExcellent compatibility with Microsoft Word formats (.docx, .docm)Familiar, easy-to-use interface with no steep learning curveSeamless transition for everyday document creation and editing
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Word date picker always show 12:00 AM?

This happens because the standard Date Picker Content Control only captures the calendar date, leaving the time field at its default 12:00 AM. To capture the precise time of a click, you must run a VBA macro using the 'Now' function.

What does 'Ambiguous name detected' mean in Word VBA?

This compile error indicates that two or more procedures (macros) in the same module share the exact same name, such as multiple 'Document_ContentControlOnEnter' events. To resolve it, you must delete or merge the duplicate procedures.

Can I save my VBA macros in a standard Word document?

No, standard Word documents (.docx) cannot store VBA macros for security reasons. You must save your document as a Macro-Enabled Document (.docm) or Macro-Enabled Template (.dotm) for the code to function.