Microsoft Office Forums

Go Back   Microsoft Office Forums > >

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


Hello,

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
  #2  
Old 12-12-2015, 10:38 PM
gmayor's Avatar
gmayor gmayor is offline Date picker content control to always show current date. Windows 7 64bit Date picker content control to always show current date. Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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?

Code:
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) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-01-2016, 01:14 PM
jmglastetter jmglastetter is offline Date picker content control to always show current date. Windows 10 Date picker content control to always show current date. Office 2016
Novice
 
Join Date: Mar 2016
Posts: 4
jmglastetter is on a distinguished road
Default

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
Reply

Tags
content control events, date pickers, vba code

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date picker content control to always show current date. 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 picker content control to always show current date. Date Field to add 10 Days to Current Date Erbwon Word 6 11-12-2012 06:17 PM
Date picker content control to always show current date. Meaning of current date vs status date when saving baselines ketanco Project 1 02-08-2012 02:20 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft