Avatar of trusnock
trusnock asked on

Future Date Calculation in Word

We have been using a Word date calculation for the last year successfully until the change to the new year.  Its now not working properly, and is showing us the wrong dates.  

http://img230.imageshack.us/img230/8747/126200925840pmqt4.jpg

We found our code via the following sites:

http://addbalance.com/word/datefields2.htm

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=wrd&Number=249902&Search=true&Forum=wrd&Words=date%20calculations&Match=And&Searchpage=0&Limit=20&Old=allposts&Main=249902

Does anyone have a set of code for Word Date Calculations that would work properly and display a date 15 days from today's date.  We are trying to make this be as seamless for our client as possible, so when the document is opened this field should be updated automatically.
Microsoft WordMicrosoft Office

Avatar of undefined
Last Comment
irudyk

8/22/2022 - Mon
GrahamSkan

It would be relatively simple with VBA. Put a bookmark i the place that the date is to appear.

The macro should be put in the document template's ThisDocument module
Private Sub Document_Open()
    Dim wdRange As Range
    Set wdRange = ActiveDocument.Bookmarks("Plus14").Range
    wdRange.Text = Format(DateAdd("d", 14, Now), "dd/mm/yy")
    ActiveDocument.Bookmarks.Add "Plus14", wdRange 'ensure that bookmark range contains the new text
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
irudyk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck