Default date in Text form field

B

brian3ps

In Word 2003, how do I set the Default date in a Text form field (Type: Date,
Fill-in enabled) to the current date?
 
G

Graham Mayor

Set the field type property to current date rather than date?

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

brian3ps

I tried that, but then the field can no longer be edited (Fill-in enable is
grayed out). I need to allow this field to be changed if necessary ... just
want it to default to the current date.
 
G

Graham Mayor

The current date is always the current date, but if you want to edit the
field, you will need instead an on-entry macro to fill the date eg assuming
the text field is bookmarked "Date1", the following will insert the current
date in that field when you tab into it, in the format of the switch - here
"dd\MM\yyyy"


Sub SetDate()
Dim sDate As Date
sDate = Format((Now), "dd/MM/yyyy")
ActiveDocument.FormFields("Date1").Result = sDate
End Sub

http://www.gmayor.com/installing_macro.htm

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

brian3ps

That did the trick. Thanks.

Graham Mayor said:
The current date is always the current date, but if you want to edit the
field, you will need instead an on-entry macro to fill the date eg assuming
the text field is bookmarked "Date1", the following will insert the current
date in that field when you tab into it, in the format of the switch - here
"dd\MM\yyyy"


Sub SetDate()
Dim sDate As Date
sDate = Format((Now), "dd/MM/yyyy")
ActiveDocument.FormFields("Date1").Result = sDate
End Sub

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