Word: Is it possible to insert a future date automatically?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a sign that I, print the night before, with daily meeting locations.
Is it possible to have the header update automatically with the next workdays
day and date?
 
Here is something to get you started.

Open a new document, set the view to view headers and footers and where you
want the day and date in your header, insert a bookmark and name that
bookmark "dateHeader". Use Alt plus F8 and assign the subroutine below a
clever name. Close out VBE and save the document as a template (you may
want to make other cusomizations in the document body before you create the
template. When you create new documents from this template, running the
subroutine below will insert the next weekday's day and date into the header
(won't pay attention to skipping a holiday though, only Saturday and
Sunday).

___________________________

Sub PutNextWorkdayInHeader()

Dim dtmTemp As Date
Dim strDayDate As String

dtmTemp = Date + 1

Select Case Weekday(dtmTemp)
Case vbSaturday
dtmTemp = dtmTemp + 2
Case vbSunday
dtmTemp = dtmTemp + 1
End Select

strDayDate = FormatDateTime(dtmTemp, vbLongDate)

ActiveDocument.Bookmarks("dateHeader").Range.InsertAfter strDayDate

End Sub

_________________________

Steve Yandl
 
I've tried the macro that you show on your site Graham but am (maybe) having
a little trouble with it. I can get it to function, but is it supposed to
automatically update in a saved document?

Example...I create a document and add "XX" number of days into the prompt.
The macro adds the requested number of days. I close the document and if I
re-open it in a month it still shows the original modified date rather than
auto-updating to add "XX" number of days to TODAYS date.

Is that the way its supposed to function? If so, is there a way around it? I
need something that auto-updates and adds "XX" number of days as I re-open it
month after month.

Thanks....Joe
 
The macro inserts the date as text. If you want to have the date update and
show the date two days hence whenever you open the document, you need a
field construction. You can get this from the linked document by fellow MVP
'macropod', which you can download from my web site and which is reproduced
at http://www.gmayor.com/insert_a_date_other_than_today.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
The field code shown on my web page shows the macropod's code modified to
use a CREATEDATE field, which will not update. The original code uses the
DATE field which will.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top