Q: How Can I Put
Calculated Dates in Word?

This is more complicated than you might imagine, primarily
because of the way our calendar is constructed. Before your head starts
spinning, realize that the hard work has been done for you. Paul Edstein has posted a
document with
alternative date fields with calculations on the Windows Secrets Word Forum.

Because it is very difficult to keep track of where fields begin and end,
I've tried to use colored text and
highlighting in the nested fields
to show which field is where. This coloring is not in the Word documents and
could end up coloring your result text if you were to use it. In tracing a
field, look for a colored or highlighted opening field delimiter
{ and then look to the right to
see the next closing delimiter }
of the same color and highlighting. Everything in between those two delimiters
is in that field.

Here is an example of a field
written in response to the request:

I need to create a fiscal year field in Word 97 that
accomplishes in Word what the following statement accomplished in English:

If today's month and day are less than or equal to June 30, display the
current year, else display current year + 1.

If today were January 31, 2015, The following expression using
that field would display: "June 30, 2015" where the year is the field
and the rest of the date is regular typed text. If today were July 1, 2015, the
same expression would display as "June 30, 2016." Please note
that the field above only produces the year; you'll need to put in the rest of
the date on your own. You probably want to be using the CREATEDATE field instead
of the date field, as well. For more on this, see Using Date Fields in Microsoft Word.

Remember that you must have Word insert the {braces}. Use
(Ctrl+F9)
when writing fields; typing them won't work.

Here's a head-spinner!
What follows is a field that gives you the date two weeks
from the day a document is created, in regular written English format:

Creation date: July 9, 2015 - desired
field result = July 23, 2015
Creation date: July 23, 2014 - desired field result = August 6, 2014
Creation date: December 20, 2014 - desired field result = January 3, 2015
Creation date: February 27, 2015 - desired field result = March 12, 2015
Creation date: February 27, 2016 - desired field date result = March 13, 2016

The colors in the sample field above represent my attempt to
match field delimiters and show nesting of fields. Line breaks have been added
for clarity and should not be a part of the actual field. I added these
modifications help illustrate what the field looks like. Those fields
shown in green contain no nested fields but may
contain references to bookmark values set by other fields. Do not try to
copy the field from this page; instead you can download a
document
containing the actual field if you want.

The field shown above was produced by a macro written by Chris Woodman as
an Add-In. It allows insertion of such a
calculated date field (up to 28 days before or after the current date) field into a Word
template in Word 6/7 97/2000/2002/2003/2007/2010/2013. It is easy to use and works well. I sure wouldn't
want to try constructing these fields by hand!

The Add-In works in all versions of Word up through 2016.
However, it may not work in the 64-bit versions. I do not know. Some
Add-Ins do not work in those versions.

Chris's Add-In is limited to +/- 28 days.

Paul Edstein's work has both supplanted and
surpassed Chris Woodman's in many ways. See below.

Paul Edstein has posted a document with alternative date fields
with calculations on the Windows Secrets Word Forum. You can download it
here.

A (possibly earlier version) backup is on Graham Mayor's site:
You are looking for
DateCalc.zip by Paul Edstein. I regularly start with this document's fields
when I need to make such a field. Again, I would never start from scratch.

Q: Can I use a date other than one of the date
fields? i.e. a date that is in response to an ASK prompt?

A: Yes. Pick your bookmark name for the ASK field
and generate that field. Then generate the complex date field using Woodman's
Add-In. Then Alt+F9 to reveal field codes and, within your field, replace
CreateDate with the name of your bookmark. Press AltF9 again to hide the codes.
What follows is such combination of an ASK field together with a modified field
giving a date 7 days before the date given in response to the ASK prompt.
These are suitable for use in a mailmerge.

I have created a template that requires a date from to date to field.
e.g. 12/1/00 to 12/7/00. Basically I want it to be the weeks beginning
date to the weeks ending date. I want this data automatically filled
each time the user creates a new document using the template.

Does anyone have any ideas on how to do this?

ThanksRob

------------

Answer 1

You need to add two things to your template - a bookmark called Date (you
can call it anything you like, but you'll have to change the reference in the
code) and a macro called AutoNew which runs when you create a new document
based on the template. It seeks out your bookmark and writes the date in the
format at that location. Here it adds 90 days, but you can change the 90 to
anything else you like.

-----------
Answer 2
I think Robert is wanting to return the date the week started on and the date
the week will end on, like from Sunday to Saturday. However I just looked at
the example dates. They are Friday to Thursday - so now I really don't know.
<grin>

Anyway Robert, if you are wanting a week start date then a function is
needed to determine the weekday and then subtract the appropriate number of
days from the current date. I modified Graham's macro slightly to include the
result of the function and changed the name of the bookmark.

For the function I used Sunday as the starting date and Saturday as the
ending date. Should you want to use other days of the week then it's just a
matter of changing the current date calculation for the Case. Case 1 is
Sunday, Case 7 is Saturday. So for example if you wanted the starting date to
be Monday, then Case 1 would be WeekStart = Date - 6, Case 2 would be
WeekStart = Date, etc.

Greg Maxey posted some powerful vba code in
this thread to use Date Picker Content Controls. It is designed to not count
certain holidays and/or weekends in calculations. The variations are set using
the tags in the result content control. Some of it is incorporated in this
macro-enabled template which you could download.