Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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)

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.

CalendarType
Type: System.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.

Calling this method might delete the Bookmark control.

Optional Parameters

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

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft