Share via


Bookmark.InsertDateTime(Object, Object, Object, Object, Object) Method

Definition

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

public void InsertDateTime (ref object DateTimeFormat, ref object InsertAsField, ref object InsertAsFullWidth, ref object DateLanguage, ref object CalendarType);
abstract member InsertDateTime : obj * obj * obj * obj * obj -> unit
Public Sub InsertDateTime (Optional ByRef DateTimeFormat As Object, Optional ByRef InsertAsField As Object, Optional ByRef InsertAsFullWidth As Object, Optional ByRef DateLanguage As Object, Optional ByRef CalendarType As Object)

Parameters

DateTimeFormat
Object

The format to be used for displaying the date or time, or both. If this argument is omitted, Microsoft Office Word uses the short-date style from the Windows Control Panel (Regional Settings icon).

InsertAsField
Object

true to insert the specified information as a TIME field; otherwise, false. The default value is true.

InsertAsFullWidth
Object

true to insert the specified information as double-byte digits; otherwise, false. This argument might not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

DateLanguage
Object

Sets the language in which to display the date or time. Can be either of the following WdDateLanguage constants: wdDateLanguageBidi or wdDateLanguageLatin. This argument might not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

CalendarType
Object

Sets the calendar type to use when displaying the date or time. Can be either of the following WdCalendarTypeBi constants: wdCalendarTypeBidi or wdCalendarTypeGregorian. This argument might not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

Examples

The following code example inserts a Bookmark control with text in the document and then inserts the date and time field into the bookmark.

This example is for a document-level customization.

private void BookmarkInsertDateTime()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "First bookmark";

    object DateTimeFormat = "MMMM dd, yyyy";
    object InsertAsField = true;
    object InsertAsFullWidth = false;

    bookmark1.InsertDateTime(ref DateTimeFormat, ref InsertAsField,
        ref InsertAsFullWidth, ref missing, ref missing);
}
Private Sub BookmarkInsertDateTime()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.Text = "First bookmark"
    Bookmark1.InsertDateTime("MMMM dd, yyyy", True, False)

End Sub

Remarks

Calling this method might delete the Bookmark control.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to