Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
A company was founded in 1997. Is there a way to make number of years in
business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
The following field construction should work:
{ = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
Lene, Looks cool, but I'm getting a Syntax error even when I follow your
procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
I tried pressing Ctrl+F9 twice to generate the double brackets, then
carefully inserting the rest of the contents...this produces the result, "2007 -1997" instead of the desired, "10". Getting closer, but not quite there, yet! "JustSomeGuy" wrote: Lene, Looks cool, but I'm getting a Syntax error even when I follow your procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
OK, got it at last; i just wasn't being careful enough with the pesky syntax.
"JustSomeGuy" wrote: I tried pressing Ctrl+F9 twice to generate the double brackets, then carefully inserting the rest of the contents...this produces the result, "2007 -1997" instead of the desired, "10". Getting closer, but not quite there, yet! "JustSomeGuy" wrote: Lene, Looks cool, but I'm getting a Syntax error even when I follow your procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
I am glad to hear it works now. I did not see your posts until you had solved
the problems. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: OK, got it at last; i just wasn't being careful enough with the pesky syntax. "JustSomeGuy" wrote: I tried pressing Ctrl+F9 twice to generate the double brackets, then carefully inserting the rest of the contents...this produces the result, "2007 -1997" instead of the desired, "10". Getting closer, but not quite there, yet! "JustSomeGuy" wrote: Lene, Looks cool, but I'm getting a Syntax error even when I follow your procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
This is very handy. For years I've seen people embedding hard dates into
corporate documents, which are doomed to become outdated, requiring manual re-editing that almost never happens because everyone's too busy. This little gem solves that problem! THANKS!! "Lene Fredborg" wrote: I am glad to hear it works now. I did not see your posts until you had solved the problems. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: OK, got it at last; i just wasn't being careful enough with the pesky syntax. "JustSomeGuy" wrote: I tried pressing Ctrl+F9 twice to generate the double brackets, then carefully inserting the rest of the contents...this produces the result, "2007 -1997" instead of the desired, "10". Getting closer, but not quite there, yet! "JustSomeGuy" wrote: Lene, Looks cool, but I'm getting a Syntax error even when I follow your procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro to calculate and insert number of elapsed years?
If you want the calculation to be even more accurate - see
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org JustSomeGuy wrote: This is very handy. For years I've seen people embedding hard dates into corporate documents, which are doomed to become outdated, requiring manual re-editing that almost never happens because everyone's too busy. This little gem solves that problem! THANKS!! "Lene Fredborg" wrote: I am glad to hear it works now. I did not see your posts until you had solved the problems. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: OK, got it at last; i just wasn't being careful enough with the pesky syntax. "JustSomeGuy" wrote: I tried pressing Ctrl+F9 twice to generate the double brackets, then carefully inserting the rest of the contents...this produces the result, "2007 -1997" instead of the desired, "10". Getting closer, but not quite there, yet! "JustSomeGuy" wrote: Lene, Looks cool, but I'm getting a Syntax error even when I follow your procedure and copy/paste your formula (from the = sign to 1977). What am I doing wrong? "Lene Fredborg" wrote: The following field construction should work: { = { DATE \@ "yyyy" } - 1997 } The construction consists of 2 fields, one inside the other. The DATE field returns the current year and 1997 is subtracted from that. The field brackets must be inserted by pressing Ctrl+F9 (field brackets cannot be typed using normal characters). Type the remaining part of the field construction between the brackets. When finished, press F9 to update the field (if this does not toggle field codes, press Alt+F9). -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "JustSomeGuy" wrote: A company was founded in 1997. Is there a way to make number of years in business, always current, in a field? i.e., embed a formula that knows "1997" and can take today's date minus 1997 and insert the number "10" so that desired boilerplate text says "We've been in business for XX years" and the number of years will always be correct, year after year, whenever the field is updated. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to calculate a date in the future | Microsoft Word Help | |||
Formula for number of days elapsed? | Tables | |||
How do I calculate the number of days between two dates? | Mailmerge | |||
Can Word calculate page number in form only if data is entered in. | Page Layout | |||
how to calculate the number of days between 2 dates in msword | Microsoft Word Help |