Calculate Date automatically in word 2007

H

Harish

Hi,

I have a report that needs to be sent out every Friday of the week. In
this report, i want the dates to be updated automatically before I
send it out. For instance, if I am going to send a report on a Friday,
i should see Monday's date as well in the report. Therefore the date
should be calculated 5 days back from the Friday's date. Therefore,
the report should consist of date 09/19/2011 - 09/23/2011

How do I get word to calculate a date 5 days before the day when i
will send out the report? Please help

Thanks,
Swamy
 
H

Harold Druss

Harish said:
Hi,

I have a report that needs to be sent out every Friday of the week. In
this report, i want the dates to be updated automatically before I
send it out. For instance, if I am going to send a report on a Friday,
i should see Monday's date as well in the report. Therefore the date
should be calculated 5 days back from the Friday's date. Therefore,
the report should consist of date 09/19/2011 - 09/23/2011

How do I get word to calculate a date 5 days before the day when i
will send out the report? Please help

Thanks,
Swamy

Hi Swamy
Here is one way using bookmarks and a macro..
===========================================================================
Sub GetFriDate()
Dim dFri As Date

dFri = Date

' get the next Friday
Do While Weekday(dFri) <> 6
dFri = dFri + 1
Loop

ActiveDocument.Bookmarks("Fridate").Range.Text = InputBox("Enter Friday
date.", "Friday's date.", dFri)

ActiveDocument.Bookmarks("Mondate").Range.Text = dFri - 4

End Sub
===========================================================================
Good luck
Harold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top