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?
 
OMC_HammerConnect With a Mentor Commented:
Create Macro:


Sub Calcuta()
    Selection.TypeText Text:=Format(Date + 29, "mmmm d, yyyy")
End Sub
0
 
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.