InsertDateTime Method
Applies To
Range object, Selection object.
Description
Inserts the current date or time, or both, either as text or as a TIME field.
Syntax
expression.InsertDateTime(DateTimeFormat, InsertAsField, InsertAsFullWidth)
expression Required. An expression that returns a Range or Selection object.
DateTimeFormat Optional Variant. The format to be used for displaying the date or time, or both. If this argument is omitted, Word uses the short-date style from Windows Control Panel (Regional Settings icon).
InsertAsField Optional Variant. True to insert the specified information as a TIME field. The default value is True.
InsertAsFullWidth Optional Variant. Not used in the U.S. English version of Microsoft Word.
See Also
Add method (Fields collection).
Example
This example inserts a TIME field for the current date. A possible result might be "November 18, 1996."
Selection.InsertDateTime DateTimeFormat:="MMMM dd, yyyy", _
InsertAsField:=True
This example inserts the current date at the end of the active document. A possible result might be "01/12/97."
With ActiveDocument.Content
.Collapse Direction:=wdCollapseEnd
.InsertDateTime DateTimeFormat:="MM/dd/yy", InsertAsField:=False
End With
This example inserts a TIME field for the current date in the footer for the active document.
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range _
.InsertDateTime DateTimeFormat:="MMMM dd, yyyy", _
InsertAsField:=True