Bookmark.InsertDateTime Method

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

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
Sub InsertDateTime ( _
    ByRef DateTimeFormat As Object, _
    ByRef InsertAsField As Object, _
    ByRef InsertAsFullWidth As Object, _
    ByRef DateLanguage As Object, _
    ByRef CalendarType As Object _
)
void InsertDateTime(
    ref Object DateTimeFormat,
    ref Object InsertAsField,
    ref Object InsertAsFullWidth,
    ref Object DateLanguage,
    ref Object CalendarType
)

Parameters

  • DateTimeFormat
    Type: System.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
    Type: System.Object%
    true to insert the specified information as a TIME field; otherwise, false. The default value is true.
  • InsertAsFullWidth
    Type: System.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
    Type: System.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.

Remarks

Calling this method might delete the Bookmark control.

Optional Parameters

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

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 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
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);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace