Thread: [Solved] Calculating dates
View Single Post
 
Old 06-08-2011, 06:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Daria11,

Yes calculating dates is complex if you need to do it with field coding. To see how to do just about everything you might want to do with date calculations in Word, check out my Microsoft Word Date Calculation Tutorial, at:
http://lounge.windowssecrets.com/ind...owtopic=249902
or
http://www.gmayor.com/downloads.htm#Third_party
Do read the document's introductory material.

However, for what you've descibed, date calculation isn't much of an issue. Try the following macro:
Code:
Sub DateUpdater()
Application.ScreenUpdating = False
Dim FRDoc As Document, FRList As String, j As Long
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .MatchWholeWord = True
  .MatchCase = True
  .Text = "+Today"
  .Replacement.Text = Format(Date, "dddd, d MMMM, YYYY")
  .Execute Replace:=wdReplaceAll
  .Text = "+1week"
  .Replacement.Text = Format(DateAdd("d", 7, Date), "dddd, d MMMM, YYYY")
  .Execute Replace:=wdReplaceAll
  .Text = "+2weeks"
  .Replacement.Text = Format(DateAdd("d", 14, Date), "dddd, d MMMM, YYYY")
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
You may need to change the date output formats to suit your needs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote