MS Word, Use Auto-date (todays date) plus twenty one days


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.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Paul,

One of the things I really dislike about word is the lack of ability to add dates in fields. Here's one way to work around it. Create the following macro:

Sub AutoOpen()

  Selection.GoTo What:=wdGoToBookmark, Name:="DatePlus21"
  Selection.InsertBefore Format((Date + 21), "MMMM dd, yyyy")

End Sub

Now in your document place a bookmark in the spot where you want the date to appear. Name the bookmark DatePlus21. Now, when you open the document, the current date plus 21 days will appear at the bookmark. You can change the format to fit your needs.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
paulppAuthor Commented:

can you create a sample file for me? is there anyway to do this without Micros?
paulppAuthor Commented:

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.

IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

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

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:

{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+Delay}}
{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.

paulppAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.