Insert auto updating date in word
' tool - which inserts the current date as text, or as a field which displays the system date (pity Microsoft didn't think to use this to insert the far more useful CREATEDATE field).Insert a date field (ALT SHIFT D), or one of the more specialized alternatives: CREATEDATE, PRINTDATE, SAVEDATE, TIME.
While in the downloads section, take a look also at Paul's excellent tutorial on Field Calculations.
Staying with the example of today plus 14 days, the code required for the task is reproduced as follows.
For ease of understanding each line is separated by a line break: - The original field construction as shown in the linked article, uses a DATE field.
The default (which you can change) is set at 14 days in the future, but you can insert and number, including negative numbers, to insert a date counted from that number before or after today's date.
Sub Insert Future Date() ' Written by Graham Mayor and posted on the word.docmanagement newsgroup in ' March 2000 ' Inserts a future date in a document - note that this is not a field ' Some style revisions and error handler by Charles Kenyon Dim Message As String Dim Mask As String Dim Title As String Dim Default As String Dim Date1 As String Dim My Value As Variant Dim My Text As String Dim Var1 As String Dim Var2 As String Dim Var3 As String Dim Var4 As String Dim Var5 As String Dim Var6 As String Dim Var7 As String Dim Var8 As String 'Date mask belowincludes non-breaking spaces (Chr(160)) Mask = "d" & Chr(160) & "MMMM" & Chr(160) & "yyyy" ' Set Date format Default = "14" ' Set default.