Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

date code question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pcupcakes - 18 Aug 2005 16:35 GMT
I am trying to modify the date code field to automatically populate a date in
my word document X number of days from the present date.  Would I be able to
modify the following to accomplish this task and if so, how would you go
about doing it?

{ DATE \@ "dddd MM/dd/yy"}

So, when this document is edited today (08/18/05), the code will produce:
Thursday 08/18/05

I want to modify the code so it is always smart enough to add X days to the
date automatically.  So, if I wanted it to display a date 7 days into the
future (X=7), output would automatically be adjusted to display:

Thursday 08/25/05

How can the date code listed above be modified to accomplish this?  Thanks.
Charles Kenyon - 18 Aug 2005 19:14 GMT
This is more complex than you might imagine, but it can be done. The
following field does a CreateDate plus 7 days.

{ QUOTE "{ SET " Delay" "7" }
{  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" }" } } } }" }

Do _not_ try to type this! See http://addbalance.com/word/datefields2.htm 
for information on the different kinds of ways to make a date calculation
work. It includes links to pages with fields and an explanation of different
macros that can be used instead of fields. It also includes a link to Chris
Woodman's Add-In that created the field you see.

Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: 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.

>I am trying to modify the date code field to automatically populate a date
>in
[quoted text clipped - 17 lines]
> How can the date code listed above be modified to accomplish this?
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.