Inserting Calculated Date in Word Document

So based on the Date that a letter is create I would like to have Word Automatically generate and insert a date 29 days into the future.


So if Today was the day the letter was created then October 3rd would be the date I would like Word to Insert
seamus9909Asked:
Who is Participating?

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

x
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.

GrahamSkanRetiredCommented:
Using VBA it is fairly simple, something like:

ActiveDocument.Bookmarks("Plus29").Range.Text = Format(DateAdd("d", 29, Now), "dd/MM/yyyy")

Open in new window

0
TazDevil1674Commented:
Which version of Word are you using?

I presume you are going to use a Template which you open each day?

For 2007, Insert > Date & Time > Select the date type you require; click Update automatically

Right-click on the date > Edit field > Field Codes

It will say something like DATE  \@ "dd/MM/yy"

Change it to DATE +29 \@ "dd/MM/yy"
0
seamus9909Author Commented:
Sorry , yes Word 2007.  I tried your example but does not work right. I have enclosed the document for your review.

At the end of this paragraph is where I want it to calculate the new date.

Since the provider  the requested information within the allotted 30-day time frame, we are commencing our review.  The initial determination will be completed within 30 days and a determination will be sent by Tuesday, September 04 2012
CommenceLetter-942012-Michael-De.docx
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

GrahamSkanRetiredCommented:
It can be done with fields, but it is a lot more complicated than putting +29 after the field name (and I think that CreateDate would be a more appropriate field, anyway). See this article
http://www.addbalance.com/word/datefields2.htm.

To use VBA, put a bookmark named "Plus29" in the template where you need the future date, Then put the code that I suggested into the Document_New procedure of the ThisDocument module of template that you use to create the document.
Option Explicit

Private Sub Document_New()
    ActiveDocument.Bookmarks("Plus29").Range.Text = Format(DateAdd("d", 29, Now), "dd/MM/yyyy")
End Sub
 

Open in new window

0
seamus9909Author Commented:
Ok so I am a total novice to Word. So I saw where to insert a bookmark and how to name it however not sure about your second part.


 Then put the code that I suggested into the Document_New procedure of the ThisDocument module of template that you use to create the document.
0
GrahamSkanRetiredCommented:
You need to find the template and open it.

Then open the VBA editor with Alt+F11.

There is tree list of projects on the left hand side. One will be the Normal template that is used to create blank documents. Your template's project will be there with the stem of the filename in brackets - i.e. without the path and the extension. Open up the tree to find Microsoft Word Objects, and open that to find the ThisDocument module. Double-click to open it in the code pane on the right.
Paste the code into there. 'Option Explicit' may be there already, If so, delete one of them. Save the project with the diskette symbol in the toolbar.

Make sure that you can run macros by adjusting the settings in the Trust Centre.

When you do File/New and select your template to create a new document, the macro should run, plugging in the later date,
0
OMC_HammerCommented:
Create Macro:


Sub Calcuta()
    Selection.TypeText Text:=Format(Date + 29, "mmmm d, yyyy")
End Sub
0

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
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 Word

From novice to tech pro — start learning today.