paulpp
asked on
MS Word, Use Auto-date (todays date) plus twenty one days
hello,
i need to create a MS Word file; that when it open it has today's date (date file is opened) plus twenty-one days added to it.
Here's the code MS uses for Today's Date "{ DATE\@ M/d/yyyy }".
I'm just not sure where to insert the code to add twenty-one more days to the Today Date.
--Paul
i need to create a MS Word file; that when it open it has today's date (date file is opened) plus twenty-one days added to it.
Here's the code MS uses for Today's Date "{ DATE\@ M/d/yyyy }".
I'm just not sure where to insert the code to add twenty-one more days to the Today Date.
--Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Flyster,
okay, i see what you've done. but i need to place this code on a word doc that's being used as a label. so the date is being repeated about thirty times on the doc.
i can only get the bookmark to work in one instance and not all thirty places on the label.
--paul
okay, i see what you've done. but i need to place this code on a word doc that's being used as a label. so the date is being repeated about thirty times on the doc.
i can only get the bookmark to work in one instance and not all thirty places on the label.
--paul
Bookmarks must have unique names to work properly.
There is no in-built date arithmetic in Word Fields, so you have to calculate when the day rolls over to the next month and the next year.
However, there are some brave people who do that sort of thing:
This site has a zipped Word document that you can download with many date calculations
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902.
Look for the field under "Calculate a day, date, month and year, using n days delay". Use the Alt + F9 toggle to see/hide the field codes. You can copy and paste it into your document, but we can only paste the result into here. It is pre-set to 14 days hence, so you need to edit that to a 1 when the code is visible. Don't forget that fields need to be updated to perform their calculation.
Note that it comprises an outer field with 32 other fields nested at various depths within it.
Alternatively you could use a macro like this:
Sub PlusThreeWeeks()
Selection.Text = Format$(DateAdd("d", 21, Now), "Long Date")
End Sub
and set up a keystroke shortcut (Tools/Customize) to insert it.
It won't update each time the document is opened. Do you need that to happen?
There is no in-built date arithmetic in Word Fields, so you have to calculate when the day rolls over to the next month and the next year.
However, there are some brave people who do that sort of thing:
This site has a zipped Word document that you can download with many date calculations
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902.
Look for the field under "Calculate a day, date, month and year, using n days delay". Use the Alt + F9 toggle to see/hide the field codes. You can copy and paste it into your document, but we can only paste the result into here. It is pre-set to 14 days hence, so you need to edit that to a 1 when the code is visible. Don't forget that fields need to be updated to perform their calculation.
Note that it comprises an outer field with 32 other fields nested at various depths within it.
Alternatively you could use a macro like this:
Sub PlusThreeWeeks()
Selection.Text = Format$(DateAdd("d", 21, Now), "Long Date")
End Sub
and set up a keystroke shortcut (Tools/Customize) to insert it.
It won't update each time the document is opened. Do you need that to happen?
Here's a field code that will work for you:
{QUOTE
{SET Delay 21}
{SET a(=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365 *b+INT(b/4 )-
INT (b/100)+INT(b/400)-32045+D elay}}
{SET e{=INT ((4*(jd+32044)+3)/146097)} }
{SET f{=jd+32044-INT(146097*e/4 )}}
{SET g{=INT((4*f+3)1461)}}
{SET h{=f-INT(1461*g/4)}}
{SET i{=INT((5*h+2)/153)}}
{SET dd{=h-INT((153*i+2)/5)+1}}
{SET mm{=i+3-12*INT(i/10)}}
{SET yy{=100*e+g-4800+INT(i/10) }}
{=mm*10^6+dd*10^4+yy \# "00'-'00'-'00"} \@ "MMM d, yyyy"}
As Graham stated, it contains a series of nested fields. You can't just copy and paste it. At the end of each line is a hard return. The way to enter this is press ctrl+f9, type QUOTE and then press enter, then ctrl+f9 and type SET Delay 21. Move your cursor between the 2 remaining }} and press enter. This should leave you with one } on the 3rd line. Continue this to the end. The last piece of code( "MMM d, yyyy" ) is where you define the date format you want displayed.
{QUOTE
{SET Delay 21}
{SET a(=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365
INT (b/100)+INT(b/400)-32045+D
{SET e{=INT ((4*(jd+32044)+3)/146097)}
{SET f{=jd+32044-INT(146097*e/4
{SET g{=INT((4*f+3)1461)}}
{SET h{=f-INT(1461*g/4)}}
{SET i{=INT((5*h+2)/153)}}
{SET dd{=h-INT((153*i+2)/5)+1}}
{SET mm{=i+3-12*INT(i/10)}}
{SET yy{=100*e+g-4800+INT(i/10)
{=mm*10^6+dd*10^4+yy \# "00'-'00'-'00"} \@ "MMM d, yyyy"}
As Graham stated, it contains a series of nested fields. You can't just copy and paste it. At the end of each line is a hard return. The way to enter this is press ctrl+f9, type QUOTE and then press enter, then ctrl+f9 and type SET Delay 21. Move your cursor between the 2 remaining }} and press enter. This should leave you with one } on the 3rd line. Continue this to the end. The last piece of code( "MMM d, yyyy" ) is where you define the date format you want displayed.
ASKER
Perfect
ASKER
can you create a sample file for me? is there anyway to do this without Micros?