![]() |
|
#2
|
||||
|
||||
|
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 |
| Tags |
| 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 |