Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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,144
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 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
 

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 12:20 AM.


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