Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

LinkBack Thread Tools Display Modes
Old 12-12-2015, 09:42 PM
lucky16 lucky16 is offline Windows 7 32bit Office 2007
Join Date: Jan 2014
Posts: 21
lucky16 is on a distinguished road
Default Date picker content control to always show current date.


I have a content control date picker in word document. How to set the date picker to show current date on opening the document. I am looking for a vba code to achieve this, as there are other content control dependent on date picker in my document.

Thank you.
Reply With Quote
Old 12-12-2015, 10:38 PM
gmayor's Avatar
gmayor gmayor is online now Windows 7 64bit Office 2010 32bit
Join Date: Aug 2014
Posts: 2,705
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice

Add the following code to the ThisDocument module of the document. Name the date content control and replace "Today's Date" in the code with the Title of the content control. Save as macro enabled document.

However, why not use instead a bookmarked date field which will always show the current date and doesn't need the macro?

Option Explicit

Private Sub Document_Open()
Dim objCC As ContentControl
Dim objDate As Date
    For Each objCC In ActiveDocument.ContentControls
        If objCC.Title = "Today's Date" Then
            objDate = Date
            objCC.Range.Text = objDate
            Exit For
        End If
    Next objCC
End Sub
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes
Reply With Quote
Old 07-01-2016, 01:14 PM
jmglastetter jmglastetter is offline Windows 10 Office 2016
Join Date: Mar 2016
Posts: 4
jmglastetter is on a distinguished road

For those looking for a non-VBA method. I have used this method successfully.

1- Insert a new date picker content control from the Developer Tab.
2- Select the Design Mode in the Developer Tab.
3- Delete the "Click here to enter a date." default text.
4- From the Insert tab, select Insert Date and Time.
5- Select the style of the default today's date style and check the Update automatically box.
6- Right click the date picker content control and select properties.
7- Select the matching date style for the date picker.
8- Turn off the Design Mode in the Developer Tab.

Will display today's date by default instead of the content control's creation date.
Reply With Quote

content control events, date pickers, vba code

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can a document have the same date modified/create date, yes have have actual file content? legaleagle Word 15 01-07-2015 06:58 PM
Possible to link a date picker to another date picker? tubbz Word 0 05-07-2014 01:23 PM
Date Picker Control Karen615 Word 3 04-02-2014 02:57 PM
Date Field to add 10 Days to Current Date Erbwon Word 6 11-12-2012 06:17 PM
Meaning of current date vs status date when saving baselines ketanco Project 1 02-08-2012 02:20 PM

All times are GMT -7. The time now is 07:29 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc. is not affiliated with Microsoft