Date/Time Field

G

Guest

Hi,

Two questions please:

We have Windows XP and Word 2003

1. How can I create a quick keystroke or toolbar button to put a basic date
code (e.g., November 11, 2007) in my document?

2. I am curious about a technical aspect of the automatically updating
date/time field. I saw a template where a date code was inserted when you
created it. But the date code had a hyphen-like character (code?) just after
the field. Someone told me that the field doesn't know to automatically
update unless this hyphen-like character/code is there. But when I put a
date field in my document by going thru the Insert menu, I don't see a
character like that appearing after the code. Can someone tell me what that
"hyphen" actually is, and how it works?

Thanks!
Rosemary
 
S

Suzanne S. Barnhill

For inserting a date in the header or footer, there is an Insert Date button
on the Header and Footer toolbar (this button could also be added to any
toolbar). Anywhere in a document, you can use the Alt+Shift+D keyboard
shortcut. Both the button and the shortcut insert a DATE field using the
format you have selected as the default in the Insert | Date and Time
dialog.

Note, however, that a DATE field is probably not what you want. What you
describe is a CREATEDATE field. For more on date fields, see
http://word.mvps.org/FAQs/TblsFldsFms/DateFields.htm. There is no built-in
shortcut for inserting this field, but you can insert the field in the usual
way (by hand or through the Insert | Field dialog), formatted as desired,
and then save it as an AutoText entry; see
http://word.mvps.org/FAQs/Customization/AutoText.htm. Once you've created
the AutoText entry, there are several ways you can insert it. The usual way
is just to type the first four letters of the entry name (which should be
something you wouldn't otherwise be typing) and press Enter or (in Word
2007) F3, but you can also assign a keyboard shortcut or toolbar button
through Tools | Customize in versions before Word 2007.

For letters and other documents that should always include the creation
date, put the CREATEDATE field in the document template. It will not update
in the template itself but will show the creation date of each document
based on the template.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

Hi Suzanne,

Thank you - that was very helpful. The site explained the differences very
well.

What we have in the template I talked about is a date code that updates
every time you open the document (which is what we need - sorry, I may not
have explained clearly).

I noticed the site said you can update on print, but not necessarily on
opening the document. I believe that "hyphen-like" character that appears
just after the date code, included by the template's creator, is what gets
the field to update each time the document is opened ...?

Regards,
Rosemary
 
G

Guest

Hi again,

Here is the code for the date field -- I think the line I am curious about is:
Selection.TypeText Text:=Chr(31)

'Date
With Selection
.Style = ActiveDocument.Styles("Normal")
If chkDate.Value = True Then 'they checked insert as field
.InsertDateTime DateTimeFormat:="MMMM d, yyyy",
InsertAsField:=True
Selection.TypeText Text:=Chr(31)
ElseIf chkDate.Value = False Then 'they did not check insert as
field
.TypeText Text:=txtDDate.Value
End If
.TypeParagraph
End With

Best regards,
Rosemary
 
S

Suzanne S. Barnhill

An ordinary DATE field would update each time the document was opened (or at
least any time that fields were updated, as when printing or switching to
Print Preview or, if it was in the header or footer, every time the document
was repaginated). Someone with some VBA knowledge will have to interpret the
macro for you; ASCII character 31 is a nonprinting character, "unit
separator," apparently used in Word as the "optional hyphen" (Ctrl+-).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

Thank you, Suzanne

Suzanne S. Barnhill said:
An ordinary DATE field would update each time the document was opened (or at
least any time that fields were updated, as when printing or switching to
Print Preview or, if it was in the header or footer, every time the document
was repaginated). Someone with some VBA knowledge will have to interpret the
macro for you; ASCII character 31 is a nonprinting character, "unit
separator," apparently used in Word as the "optional hyphen" (Ctrl+-).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Graham Mayor

The code reproduced has little to do with the Insert Date function. The
character has nothing to do with whether the date will update or not. That
is determined by

If chkDate.Value = True Then

which refers to an object chkDate which is not defined in the section of
code you have reproduced and presumably refers to a user checked box in the
document or in a userform and based on whether the value is true or false
(checked or not) the date is either inserted as a field or as text defined
elsewhere in txtDDate.Value

If you merely want to insert a date field, as the thread implies then

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

is the code required to do that.
http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top