Muokkaa

Jaa


Selection.InsertDateTime method (Word)

Inserts the current date or time, or both, either as text or as a TIME field.

Syntax

expression. InsertDateTime( _DateTimeFormat_ , _InsertAsField_ , _InsertAsFullWidth_ , _DateLanguage_ , _CalendarType_ )

expression Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
DateTimeFormat Optional Variant The format to be used for displaying the date or time, or both. If this argument is omitted, Microsoft Word uses the short-date style from the Windows Control Panel (Regional Settings icon). See Date/Time data type for format symbols.
InsertAsField Optional Variant True to insert the specified information as a TIME field. The default value is True.
InsertAsFullWidth Optional Variant True to insert the specified information as double-byte digits. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.
DateLanguage Optional Variant Sets the language in which to display the date or time. Can be either of the WdDateLanguage constants. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.
CalendarType Optional Variant Sets the calendar type to use when displaying the date or time. Can be either of the WdCalendarTypeBi constants. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

Remarks

Using this method replaces the current selection. To avoid this, use the Collapse method before using this method.

Example

This example inserts a TIME field for the current date. A possible result might be "November 18, 1999."

Selection.InsertDateTime DateTimeFormat:="MMMM dd, yyyy", _ 
 InsertAsField:=True

See also

Selection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.