?
Solved

Inserting Calculated Date in Word Document

Posted on 2012-09-04
7
Medium Priority
?
3,212 Views
Last Modified: 2012-09-11
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
0
Comment
Question by:seamus9909
7 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38364087
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
 
LVL 9

Expert Comment

by:TazDevil1674
ID: 38364125
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
 

Author Comment

by:seamus9909
ID: 38364352
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38364497
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
 

Author Comment

by:seamus9909
ID: 38364737
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38365286
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
 
LVL 2

Accepted Solution

by:
OMC_Hammer earned 2000 total points
ID: 38369558
Create Macro:


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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question