This topic has not yet been rated - Rate this topic

TextRange.InsertDateTime Method

Office 2007
Returns a TextRange object that represents the date and time inserted into a specified text range.

Syntax

expression.InsertDateTime(Format, InsertAsField, InsertAsFullWidth, Language, Calendar)

expression   A variable that represents a TextRange object.

Parameters

NameRequired/OptionalData TypeDescription
FormatRequiredPbDateTimeFormatA format for the date and time.
InsertAsFieldOptionalBooleanTrue for Microsoft Office Publisher to update date and time whenever opening the publication. Default is False.
InsertAsFullWidthOptionalBooleanTrue 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. Default is False.
LanguageOptionalMsoLanguageIDThe language in which to display the date or time.
CalendarOptionalPbCalendarTypeThe calendar type to use when displaying the date or time.

Return Value
TextRange

Remarks

The Format parameter can be one of the PbDateTimeFormat constants declared in the Microsoft Office Publisher type library.

The Language parameter can be one of the MsoLanguageID constants declared in the Microsoft Office type library.

The Calendar parameter can be one of the PbCalendarType constants declared in the Microsoft Office Publisher type library. The default is pbCalendarTypeWestern.

Example

This example inserts a field for the current date at the cursor position.

Visual Basic for Applications
Sub InsertDateField()
    Selection.TextRange.InsertDateTime Format:=pbDateLong, InsertAsField:=True
End Sub



Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.