Inserting today's date + 14 days by default

W

Wowbagger

In Word 2k3 I have a text form field of type Date. I would like it to
default to today's date +14 days. How do I express this in the Default
date: field on the field property screen?

--
Thanks

"He had had his immortality thrust upon him by an unfortunate accident with
an irrational particle accelerator, a liquid lunch and a pair of rubber
bands. The precise details of the accident are not important because no one
has ever managed to duplicate the exact circumstances under which it
happened, and many people have ended up looking very silly, or dead, or
both, trying."
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Run a macro that contains the following code on entry to that formfield or
on entry or exit from anyother one on your form.

ActiveDocument.Formfields("bmname").Result = Format(DateAdd("d", 14, Date),
"MMMM d, yyyy")

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
N

Name

This is complicated to do with fields - see
http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=wrd&Number=249902
The alternative is to use macro code running on exit from the form field to
place the calculated date where you require it.
Doug's suggested macro is actually quite straightforward. I had a date
question recently which was also referred to the above link. Although
the attachment at the link is described as "showing how to do date &
time calculations," it actually only showed that they could be done, not
"how." I guess the idea is to dissect the .doc file into its more
primitive background coding, but there really is no "how" explanation
included with the file itself.
 
C

Charles Kenyon

The document at that location has the necessary fields. Here is one based on
a CREATEDATE field:

{ QUOTE "{ SET " Delay" "14" }
{ SET "DaysInMonth" { IF { CreateDate \@ "MM" } <> 2
{ = ROUND(30.575*{ CreateDate \@ "MM" },0)-
ROUND(30.575*{ = { CreateDate \@ "MM" } -1 },0) }
{ IF { = MOD( { CreateDate \@"yy" } , 4 ) } > 0 "28" "29" } } }
{ SET "NextMonth" { IF { CreateDate \@ "MM" } = 12 "1/97"
"{ = { CreateDate \@ "MM" } + 1 }/97 } }
{ IF { = { REF "Delay" } + { CreateDate \@ "dd" } } <= {
REF"DaysInMonth" }
{ CreateDate \@ "MMMM { = { REF "Delay" } + { CreateDate \@ "dd" } },
yyyy"}{ QUOTE { NextMonth \@ "MMMM" }
{ = { REF "Delay" } + { CreateDate \@ "dd" } - { REF"DaysInMonth" } },
{ IF { CreateDate \@ "MM" } <> 12 { CreateDate \@ "yyyy" }
{ CreateDate \@ "{ = 1 + { CreateDate \@ "yyyy" } \# "xxxx" }" } } } }" }

As you can see, it isn't simple. That field was created by an Add-In that is
simple to use. You can download it from <URL:
http://www.chriswoodman.co.uk/Delayed Dates.htm>.

--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
G

Graham Mayor

Name said:
Doug's suggested macro is actually quite straightforward. I had a
date question recently which was also referred to the above link.
Although
the attachment at the link is described as "showing how to do date &
time calculations," it actually only showed that they could be done,
not "how." I guess the idea is to dissect the .doc file into its more
primitive background coding, but there really is no "how" explanation
included with the file itself.

I did say that it was complicated :) The fields are all included in the
document (ALT+F9 to display them). A macro is much simpler where it can be
accommodated.

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
M

macropod

Hi Graham,

I must say it had never occurred to me that people interested in how to use
fields for date calcs wouldn't know how to display field codes, using Alt-F9
for the whole document, or Shift-F9 for a single field. One for the next
update.

Cheers
 
N

Name

I must say it had never occurred to me that people interested in how to use
fields for date calcs wouldn't know how to display field codes, using Alt-F9
for the whole document, or Shift-F9 for a single field. One for the next
update.
Yep, that's me. :)
Thanks for that additional bit of information.
 

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