View Single Post
 
Old 12-12-2015, 10:38 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit 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